In the config file, set the include/exclude key to make hexo explicitly process or ignore certain files/folders. You can use glob expressions for path matching.
Hexo by default ignores hidden files and folders (including files and folders with a name that start with an underscore, with an exception*), but setting this field will make Hexo process them.
Hexo process will ignore files list under this field.
# Include/Exclude Files/Folders include: -".nojekyll" # Include 'source/css/_typing.css'. -"css/_typing.css" # Include any file in 'source/_css/'. -"_css/*" # Include any file and subfolder in 'source/_css/'. -"_css/**/*"
exclude: # Exclude 'source/js/test.js'. -"js/test.js" # Exclude any file in 'source/js/'. -"js/*" # Exclude any file and subfolder in 'source/js/'. -"js/**/*" # Exclude any file with filename that starts with 'test' in 'source/js/'. -"js/test*" # Exclude any file with filename that starts with 'test' in 'source/js/' and its subfolders. -"js/**/test*" # Do not use this to exclude posts in the 'source/_posts/'. # Use skip_render for that. Or prepend an underscore to the filename. # - "_posts/hello-world.md" # Does not work.
Each value in the list must be enclosed with single/double quotes.
include: and exclude: do not apply to the themes/ folder. Prepend an underscore to the files or folders name in that folder to exclude them.
Notable exception is the source/_posts folder, but any file or folder with a name that starts with an underscore under that folder would still be ignored. Using include: rule in that folder is not recommended.
Using an Alternate Config
A custom config file path can be specified by adding the --config flag to your hexo commands with a path to an alternate YAML or JSON config file, or a comma-separated list (no spaces) of multiple YAML or JSON files.
# use 'custom.yml' in place of '_config.yml' $ hexo server --config custom.yml
# use 'custom.yml' & 'custom2.json', prioritizing 'custom2.json' $ hexo server --config custom.yml,custom2.json
Using multiple files combines all the config files and saves the merged settings to _multiconfig.yml. The later values take precedence. It works with any number of JSON and YAML files with arbitrarily deep objects. Note that no spaces are allowed in the list.
For instance, in the above example if foo: bar is in custom.yml, but "foo": "dinosaur" is in custom2.json, _multiconfig.yml will contain foo: dinosaur.
Overriding Theme Config
Hexo themes are independent projects, with separate _config.yml files.
Instead of forking a theme, and maintaining a custom branch with your settings, you can configure it from your site’s primary configuration file.