Skip to content

./img/ not being copied to ./_site/img/ on Netlify, nor locally unless I change eleventy.config.js while site is being --served #4204

@autonomousapps

Description

@autonomousapps

Operating system

macOS Sequoia 15.6.1 locally, and whatever netlify is using

Eleventy

3.1.2

Describe the bug

I originally posted about this on the eleventy discord.

Please note that while I'm providing local repro steps, I noticed this issue because my site isn't working as expected after being built by Netlify. To build my site on Netlify, I simply gave it access to my private Github repo. It apparently "knows" how to build 11ty-generated sites. It invokes npm run build, which in turns becomes npx @11ty/eleventy. My site is based on this template.

Local repro steps:

  1. Add the below two blocks of code to eleventy.config.js.
  2. In some content, call the ogImageHtml function.
  3. Run npx @11ty/eleventy --serve
  4. Observe that an ./img/ directory has been created, I assume by the ogImageHtml function.
  5. Observe that there is no directory named ./_site/img/
  6. Run touch eleventy.config.js
  7. Now observe that there is a directory ./_site/img/

Consequences: building my site on Netlify results in no ./_site/img/ directory, breaking expected functionality of my site.

Context

I have eleventyConfig.addPassthroughCopy("img"); in my config file. I also have this:

    eleventyConfig.addShortcode("ogImageHtml", async function (src) {
        let metadata = await Image(src, {
            widths: ["auto"],
            formats: ["jpeg", "webp", "png"],
        });

        let data = metadata.jpeg[metadata.jpeg.length - 1];
        return `<meta property="og:image" content="https://autonomousapps.com${data.url}">`;
    });

Reproduction Source Code URL

No response

Screenshots

Screenshot of the available directories on Netlify after a build. Observe no img dir.
Image

Full output from Netlify's build step:

2:27:41 PM: Netlify Build                                                 
2:27:41 PM: ────────────────────────────────────────────────────────────────
2:27:41 PM: ​
2:27:41 PM: ❯ Version
2:27:41 PM:   @netlify/build 35.5.9
2:27:41 PM: ​
2:27:41 PM: ❯ Flags
2:27:41 PM:   accountId: 692b49c1bf5de8f9fffd1051
2:27:41 PM:   baseRelDir: true
2:27:41 PM:   buildId: 694b1754440e5c00083161df
2:27:41 PM:   deployId: 694b1754440e5c00083161e1
2:27:41 PM: ​
2:27:41 PM: ❯ Current directory
2:27:41 PM:   /opt/build/repo
2:27:41 PM: ​
2:27:41 PM: ❯ Config file
2:27:41 PM:   /opt/build/repo/netlify.toml
2:27:41 PM: ​
2:27:41 PM: ❯ Context
2:27:41 PM:   production
2:27:41 PM: ​
2:27:41 PM: build.command from netlify.toml                               
2:27:41 PM: ────────────────────────────────────────────────────────────────
2:27:41 PM: ​
2:27:41 PM: $ npm run build
2:27:41 PM: > eleventy-base-blog@9.0.0 build
2:27:41 PM: > npx @11ty/eleventy
2:27:43 PM: [11ty/eleventy-img] Processing https://s3.amazonaws.com/theoatmeal-img/comics/reaching_people/reaching_people.png (transform)
2:27:43 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-1.png (transform)
2:27:43 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-2.png (transform)
2:27:43 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-3.png (transform)
2:27:58 PM: [11ty/eleventy-img] Processing ./content/blog/java-cursed/conspiracy.webp (transform)
2:27:58 PM: [11ty/eleventy-img] Processing ./content/blog/java-cursed/baba-yaga.jpg (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/when-pom-files-lie/water-drain.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/when-pom-files-lie/draw-the-owl.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/extensions-part-2-shenanigans/forest.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/extensions-part-2-shenanigans/search-results.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/one-click-dependencies-fix/derelict.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/one-click-dependencies-fix/task-graph.webp (transform)
2:28:04 PM: [11ty/eleventy-img] Processing https://images.chesscomfiles.com/uploads/v1/blog/330360.a19e1d43.630x354o.887da26c7541.png (transform)
2:28:04 PM: [11ty] Writing ./_site/feed/feed.xml from ./content/eleventy-plugin-feed-blog-title-atom.njk (virtual)
2:28:04 PM: [11ty] Writing ./_site/sitemap.xml from ./content/sitemap.xml.njk
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/when-pom-files-lie/hero.webp
2:28:04 PM: [11ty/eleventy-img] Processing ./content/about/profile.jpg (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/about/github-mark.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/about/mastodon-black.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing https://images.chesscomfiles.com/uploads/v1/blog/330360.a19e1d43.630x354o.887da26c7541.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing https://s3.amazonaws.com/theoatmeal-img/comics/reaching_people/reaching_people.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-1.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-2.png (transform)
2:28:04 PM: [11ty] Writing ./_site/tags/index.html from ./content/tags.njk
2:28:04 PM: [11ty] Writing ./_site/blog/index.html from ./content/blog.njk
2:28:04 PM: [11ty] Writing ./_site/index.html from ./content/index.njk
2:28:04 PM: [11ty] Writing ./_site/podcasts/index.html from ./content/podcasts.njk
2:28:04 PM: [11ty] Writing ./_site/tags/android/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/kotlin/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/dagger/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/ai/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/enshittification/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/gradle/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/tags/java/index.html from ./content/tag-pages.njk
2:28:04 PM: [11ty] Writing ./_site/404.html from ./content/404.md (njk)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/enshittification/enshittification-3.png (transform)
2:28:04 PM: [11ty/eleventy-img] Processing ./content/blog/extensions-part-2-shenanigans/forest.webp (transform)
2:28:05 PM: [11ty/eleventy-img] Processing ./content/blog/extensions-part-2-shenanigans/search-results.webp (transform)
2:28:06 PM: [11ty/eleventy-img] Processing ./content/blog/one-click-dependencies-fix/derelict.webp (transform)
2:28:06 PM: [11ty/eleventy-img] Processing ./content/blog/one-click-dependencies-fix/task-graph.webp (transform)
2:28:06 PM: [11ty] Writing ./_site/about/index.html from ./content/about/about.md (njk)
2:28:06 PM: [11ty] Writing ./_site/blog/chess-dot-com/post/index.html from ./content/blog/chess-dot-com/post.md (njk)
2:28:07 PM: [11ty/eleventy-img] Processing ./content/blog/java-cursed/conspiracy.webp (transform)
2:28:08 PM: [11ty/eleventy-img] Processing ./content/blog/java-cursed/baba-yaga.jpg (transform)
2:28:08 PM: [11ty/eleventy-img] Processing ./content/blog/when-pom-files-lie/water-drain.webp (transform)
2:28:08 PM: [11ty] Writing ./_site/blog/extensions-part-2-shenanigans/post/index.html from ./content/blog/extensions-part-2-shenanigans/post.md (njk)
2:28:09 PM: [11ty/eleventy-img] Processing ./content/blog/when-pom-files-lie/draw-the-owl.webp (transform)
2:28:09 PM: [11ty] Writing ./_site/blog/one-click-dependencies-fix/post/index.html from ./content/blog/one-click-dependencies-fix/post.md (njk)
2:28:12 PM: [11ty] Writing ./_site/blog/when-pom-files-lie/post/index.html from ./content/blog/when-pom-files-lie/post.md (njk)
2:28:18 PM: [11ty] Writing ./_site/blog/java-cursed/post/index.html from ./content/blog/java-cursed/post.md (njk)
2:28:24 PM: [11ty] Writing ./_site/blog/enshittification/post/index.html from ./content/blog/enshittification/post.md (njk)
2:28:24 PM: [11ty/eleventy-img] 26 images optimized
2:28:24 PM: [11ty] Copied 2 Wrote 21 files in 41.65 seconds (1983.5ms each, v3.1.2)
2:28:24 PM: ​
2:28:24 PM: (build.command completed in 43s)
2:28:24 PM: ​
2:28:24 PM: (Netlify Build completed in 43.5s)
2:28:25 PM: Section completed: building
2:28:26 PM: Finished processing build request in 52.516s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions