Skip to navigation Skip to main content
Eleventy
Eleventy Documentation
Stable
2.0.1
Toggle Menu
Eleventy 5.81s
Remix 40.14s

Ignore Template Files

Contents

Add an .eleventyignore file to your input directory or project root directory for a new line-separated list of files (or globs) that will not be processed by Eleventy. Note that any paths listed in your project’s .gitignore file are automatically ignored—you don’t need to duplicate them to your .eleventyignore file. Layouts, include files, extends, partials, macros, and other lower level template features aren’t relevant to this feature.

Sample .eleventyignore

Filename .eleventyignore
README.md
_drafts/
secretNunjucksTemplates/anotherFolder/**/*.njk

Configuration API

You can programmatically add and delete ignores in your configuration file. eleventyConfig.ignores is a JavaScript Set.

The ignores Set starts with a default **/node_modules/** entry in Eleventy v2.0 (it was node_modules/** in v1.0).

eleventy.config.js
export default function (eleventyConfig) {
eleventyConfig.ignores.add("README.md");
eleventyConfig.ignores.delete("README.md");
};
module.exports = function (eleventyConfig) {
eleventyConfig.ignores.add("README.md");
eleventyConfig.ignores.delete("README.md");
};

Added in v2.0.0These were decoupled from the ignores used for the file watcher.

You can also use the new Preprocessor Configuration API to ignore files.

Defaults

.gitignore entries

Paths listed in your project’s .gitignore file are automatically ignored. You can opt-out of this behavior.

node_modules

node_modules folders are always ignored by Eleventy. This makes new Eleventy projects easier and helps developers new to Eleventy get ramped up easier too.

INFO:
The node_modules behavior in Eleventy 1.0 only ignores the project root node_modules/**. Eleventy 2.0.0-canary.15 and newer ignores all node_modules folders using **/node_modules/**.

If you want to opt-out and search for templates inside of your node_modules folder, delete the entry using the Configuration API:

eleventy.config.js
export default function (eleventyConfig) {
// in Eleventy 2.0
eleventyConfig.ignores.delete("**/node_modules/**");

// in Eleventy 1.0
eleventyConfig.ignores.delete("node_modules/**");
};
module.exports = function (eleventyConfig) {
// in Eleventy 2.0
eleventyConfig.ignores.delete("**/node_modules/**");

// in Eleventy 1.0
eleventyConfig.ignores.delete("node_modules/**");
};
INFO:
The node_modules behavior changed in Eleventy 1.0. If you’re still using Eleventy 0.x, read the 0.x documentation.

Ignore File Locations

We look for ignores in these files. Entries are relative to the ignore file’s location.

  • Project root directory (top level, where you ran Eleventy from)
    • .eleventyignore
    • .gitignore
  • Input directory (while this matches the project root by default, these can be different using --input)
    • .eleventyignore
INFO:
Starting in Eleventy 1.0 support for a .gitignore file in a separate input directory was removed. Read more at Issue #364.

Opt-out of using .gitignore

You can disable automatic use of your .gitignore file by using the Configuration API method: eleventyConfig.setUseGitIgnore(false);.

eleventy.config.js
export default function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
};
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
};

When using .gitignore is disabled, .eleventyignore will be the single source of truth for ignored files. This also means that your node_modules directory will be processed unless otherwise specified in your .eleventyignore file.


Other pages in Configuration: