Documentation Pages
Plugins #
New in v0.2.13
Plugins are custom code that Eleventy can import into a project from an external repository.
List of Official Plugins #
eleventy-plugin-rss
is a collection of Nunjucks filters for RSS/Atom feed templates.eleventy-plugin-syntaxhighlight
for syntax highlighting using Markdown and Liquid tags.eleventy-plugin-inclusive-language
includes a simple linter to help your writing use more inclusive language. Inspired by CSS Tricks’ Words to Avoid in Educational Writing.
Unofficial Plugins #
eleventy-plugin-toc
by James Steinbach will generate a table of contents from your headings.eleventy-plugin-cache-buster
by mightyplow will add content hashes to JavaScript and CSS resources.- Search for
eleventy-plugin
onnpm
Adding a Plugin #
Install the plugin through npm. #
npm install @11ty/eleventy-plugin-rss --save
Add the plugin to Eleventy in your config file #
Your config file is probably named .eleventy.js
.
Filename .eleventy.js
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
};
Plugin Configuration Options #
New in v0.5.4 Use an optional second argument to addPlugin
to customize your plugin’s behavior. These options are specific to the plugin. Please consult the plugin’s documentation (e.g. the eleventy-plugin-syntaxhighlight
README) to learn what options are available to you.
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginSyntaxHighlight, {
// only install the markdown highlighter
templateFormats: ["md"],
init: function({ Prism }) {
// Add your own custom language to Prism!
}
});
};
Namespace the plugin additions #
You can namespace parts of your configuration using eleventyConfig.namespace
. This will add a string prefix to all filters, tags, helpers, collections, and transforms.
Filename .eleventy.js
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.namespace("myPrefix_", () => {
// the rssLastUpdatedDate filter is now myPrefix_rssLastUpdatedDate
eleventyConfig.addPlugin(pluginRss);
});
};
Plugin namespacing is an application feature and should not be used if you are creating your own plugin (in your plugin configuration code). Follow along at Issue #256.