Files specified in keep_files are removed by jekyll clean

The question is mainly for the developers. Files in _site directory and specified in keep_files in the config are deleted when I run jekyll clean. I am not sure if it is bug or normal behavior and should I report it on GitHub?

_site/ is the directory generated by jekyll build, hence it is the output of the build and the focus of jekyll clean.

keep_files option must prevent specified files in destination directory from deletion.

In the docs it states:

Useful for files that are not generated by jekyll; e.g. files or assets that are generated by your build tool.

So if the files were generated by jekyll, they’ll probably be deleted.

But how to make “raw” files in my site? For example, I want to make a file with following content:

hello world

This file should be served on my site “as is”, without any changes.

But Jekyll will generate an error because it sees front matter with incorrect format. How to stop Jekyll from processing several files that look like files with front matter and make it keep it “as is”?

In other discussion someone advised me to put this file to _site directory and add it to keep_files in config. jekyll build does not remove it but jekyll clean does. How to prevent jekyll clean from deleting this file?

not an answer but why are you using jekyll clean? both build and serve remove all the files except the keep_files ones.

Just curious, never even knew there was a clean command.

What is the reason for the file with the incorrectly formatted front matter? without the front matter it would get moved to the site folder no problem.

@rdyar me neither. Never ever used jekyll clean.

@t1m013y maybe {% raw %} and {% endraw %} might help? Also there is a render_with_liquid: false option.

What if file contains {% endraw %}? Or how to put many raw files (it’s very uncomfortably to add {% raw %} and {% endraw %} to every file. I think it’s Jekyll issue and developers should add config option like raw_files. Files that specified in raw_files should be copied “as is”, without liquid or front matter processing.