Copy unprocessed static files, including HTML, to output directory #1889
-
I have a folder "old" which contains some static versions of older sites of mine. I would like 11ty to copy this to the output directory as is, untouched, without processing them. They contain a mix of files, including images, css, html and possibly others I don't know about (they are old sites). I just want them copied to the output directory, "_site" in my case. So I've added something like this to my elventy.js file: eleventyConfig.addPassthroughCopy("old"); Which I was hoping would simply copy "old" and everything in it to "_site/old". But I am not having much luck getting this to work. Before digging deeper into what I have done, could someone please confirm whether this is what addPassThroughCopy is supposed to do? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think this largely depends on how your project is set up, and where your "old/" folder lives.
Here's what my sample project looks like: tree -aI node_modules
.
├── .eleventy.js
├── old/
│ ├── site.css
│ ├── site.html
│ ├── site.js
│ └── site.png
├── package-lock.json
├── package.json
├── src/ ########## My input directory
│ ├── assets/
│ │ ├── foo.css
│ │ ├── foo.js
│ │ └── foo.png
│ └── index.njk
└── www/ ######### My output directory
├── assets/
│ ├── foo.css
│ ├── foo.js
│ └── foo.png
├── index.html
└── old/
├── site.css
├── site.html
├── site.js
└── site.png
6 directories, 19 files Any my .eleventy.js config file looks like this: module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("old");
eleventyConfig.addPassthroughCopy("src/assets");
return {
dir: {
input: "src",
output: "www",
}
};
}; Note that my site's files are all in the src/ directory, and my old/ directory is at the same level (mainly since I don't want Eleventy processing anything in that old/ directory). So my passthrough copy for old/ looks like: // This will copy everything from `./old/*` to `./www/old/*`.
eleventyConfig.addPassthroughCopy("old"); In the case of copying my site's static assets, I use the following: // This will copy everything from `./src/assets/*` to `./www/assets/*`.
// Note that "since passthrough file copy entries are relative to the root of your project
// and not your Eleventy input directory", we need to explicitly specify the `src/` bit here.
eleventyConfig.addPassthroughCopy("src/assets"); |
Beta Was this translation helpful? Give feedback.
I think this largely depends on how your project is set up, and where your "old/" folder lives.
The one gotcha I always forget about is: https://www.11ty.dev/docs/copy/#manual-passthrough-file-copy-(faster)
Here's what my sample project looks like: