-
Building doesn't seem to remove files that I deleted in the project from the _site directory. My start script is: " I have a directory I changed the name of that file to fundo_sand.jpg I then rebuilt the project, expecting the background of the site to be gone, because I didn't change the code in the css file. But the background was NOT gone. After doing some checking, I discovered that the In the /blog version, there were only two files: But in the _site version there were 4 files: I tried deleting the _site directory BEFORE I did the build and the new_site directory does NOT have the deleted files It appears that when I rebuild without deleting the _site directory, eleventy just adds any new files, but doesn't remove any files that were removed from the project. Am I doing something wrong? Is there a way to make sure rebuilding removes obsolete files? I had originally thought that I would just remove the _site directory from the project before every rebuild (Is there a way to do that with the build script?). But I plan to use rsync to upload any changes to the site to my server. I'm no expert on how rsync functions "under the hood", but I'm concerned that if I have a completely new _site directory, rsync won't know which files in the new _site directory are the same as those corresponding files on the server and it will upload the entire new contents of the _site directory. I don't want to re-upload the entire site every time I add a new post. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Correct, Eleventy doesn't delete the
Personally I either do a |
Beta Was this translation helpful? Give feedback.
-
Thanks again!
|
Beta Was this translation helpful? Give feedback.
-
Coming from Jekyll, I didn't even consider that 11ty wouldn't clean the output The solution chosen here does not seem to work in the future (2025). There is now a plugin by kentaroi but it seems complicated (keeps track of, and deletes only 11ty generated files) and this function should really be built into 11ty imo. I've updated the above full delete commands to completely remove the contents of const fullclean = require('del').deleteSync;
module.exports = function (eleventyConfig) {
fullclean('_site/*');
// rest of .eleventy.js config
}; I renamed Edit: I've updated the code from |
Beta Was this translation helpful? Give feedback.
Correct, Eleventy doesn't delete the
dir.output
folder before each build.We have a few existing issues around that, for your reading pleasure:
Personally I either do a
prebuild
script in my package.json file (which automatically gets run beforenpm run build
script) which runs rm -rf www/, which works for me on macOS. If you want to be fancier (and more cross-env compatible) you could also use the rimraf or del modules in your .eleventy.js file. Not sure how that impacts Eleventy incremental builds, probably quite poorly; but I personally don't use incremental builds so #yolo.