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.
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);
};
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 | Read more about Filters |
✅ Eleventy Universal Filters | {% name | filterName %} (see eleventyConfig.addFilter documentation) |