Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (77 sloc) 5.62 KB
eleventyNavigation
parent key order
Configuration
Plugins
6

Plugins {% addedin "0.2.13" %}

Plugins are custom code that Eleventy can import into a project from an external repository.

List of Official Plugins

All official plugins live under the @11ty npm organization and plugin names will include the @11ty/ prefix.

{{ collections.all | eleventyNavigation("Plugins") | eleventyNavigationToHtml({ showExcerpt: true }) | safe }}

Unofficial Plugins

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.

{% codetitle ".eleventy.js" %}

const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(pluginRss);
};

Plugin Configuration Options {% addedin "0.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, shortcodes (as of 0.7.0), collections, and transforms.

{% codetitle ".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);
  });
};

{% callout %} 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. {% endcallout %}

Community Resources

You can’t perform that action at this time.