11ty

Eleventy Documentation

⚠️ This documentation is for an older version. Go to the newest Eleventy docs or check out the full release history.

Documentation Pages

Nunjucks

Template Languages:

Eleventy Short Name File Extension NPM Package
njk .njk nunjucks

You can override a .njk file’s template engine. Read more at Changing a Template’s Rendering Engine.

Use your Nunjucks Environment #

New in Eleventy v0.3.0: As an escape mechanism for advanced usage, pass in your own instance of a Nunjucks Environment using the Configuration API.

module.exports = function(eleventyConfig) {
let Nunjucks = require("nunjucks");
let nunjucksEnvironment = new Nunjucks.Environment(
new Nunjucks.FileSystemLoader("_includes")
);
eleventyConfig.setLibrary("njk", nunjucksEnvironment);
};

Supported Features #

Feature Syntax
✅ Includes {% include 'included.njk' %} looks in _includes/included.njk
✅ Extends {% extends 'base.njk' %} looks in _includes/base.njk
✅ Imports {% import 'macros.njk' %} looks in _includes/macros.njk
✅ Filters `{% name
Eleventy Universal Filters `{% name