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

Mustache

Contents

Eleventy Short Name File Extension npm Package
mustache .mustache mustache.js

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

Installation

The ejs templating language was moved out of Eleventy core in v3 and now requires a plugin installation.

npm install @11ty/eleventy-plugin-mustache

Add to your configuration file:

eleventy.config.js
import mustachePlugin from "@11ty/eleventy-plugin-mustache";

export default function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin);
}
const mustachePlugin = require("@11ty/eleventy-plugin-mustache");

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin);
}

Use more options:

eleventy.config.js
import mustache from "mustache";
import mustachePlugin from "@11ty/eleventy-plugin-mustache";

export default function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin, {
// Override the `mustache` library instance
eleventyLibraryOverride: mustache,
});
}
const mustache = require("mustache");
const mustachePlugin = require("@11ty/eleventy-plugin-mustache");

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin, {
// Override the `mustache` library instance
eleventyLibraryOverride: mustache,
});
}

Supported Features

Feature Syntax
✅ Partials {{> user}} looks for _includes/user.mustache. Does not process front matter in the include file.
🚫 Partials (Relative Path) Not yet supported: {{> ./user}} looks for user.mustache in the template’s current directory.

Other pages in Template Languages: