--- eleventyNavigation: parent: Template Languages key: Markdown pinned: true order: 2 layout: layouts/langs.njk logoImage: "/img/logos/markdown.svg" relatedLinks: /docs/config/#default-template-engine-for-markdown-files: Default Template Engine for Markdown Files --- {% tableofcontents "open" %} | Eleventy Short Name | File Extension | npm Package | | ------------------- | -------------- | ---------------------------------------------------------- | | `md` | `.md` | [`markdown-it`](https://www.npmjs.com/package/markdown-it) | * Related languages: [MDX](/docs/languages/mdx/) | Eleventy version | `markdown-it` version | | --- | --- | | `@11ty/eleventy@0.x` | `markdown-it@10.x` | | `@11ty/eleventy@1.x` | `markdown-it@12.x` | | `@11ty/eleventy@2.x` | `markdown-it@13.x` | | `@11ty/eleventy@3.x` | `markdown-it@14.x` | {% callout "info" %} Markdown files are by default pre-processed as Liquid templates. You can change this default in your configuration file (or disable it altogether). To change this for a single template and not globally, read Changing a Template’s Rendering Engine. {% endcallout %} ## Markdown Options ### Default Options - `html: true` (`markdown-it` default is `false`) The only listed options here are the ones that differ from the default `markdown-it` options. See [all `markdown-it` options and defaults](https://github.com/markdown-it/markdown-it#init-with-presets-and-options). Starting in Eleventy 2.0, we’ve disabled the [Indented Code Blocks](#indented-code-blocks) feature by default. ### Optional: Set your own library instance {% addedin "0.3.0" %} Pass in your own instance of the Markdown library using the Configuration API. See [all `markdown-it` options](https://github.com/markdown-it/markdown-it#init-with-presets-and-options). {% set codeContent %} import markdownIt from "markdown-it"; export default function (eleventyConfig) { let options = { html: true, breaks: true, linkify: true, }; eleventyConfig.setLibrary("md", markdownIt(options)); }; {% endset %} {% include "snippets/configDefinition.njk" %} ### Optional: Amend the Library instance {% addedin "2.0.0" %} Run your own callback on the provided Library instance (the default _or_ any provided by `setLibrary` above). {% set codeContent %} export default function (eleventyConfig) { eleventyConfig.amendLibrary("md", (mdLib) => mdLib.enable("code")); }; {% endset %} {% include "snippets/configDefinition.njk" %} ## Add your own plugins {% addedin "0.3.0" %} Pass in your own `markdown-it` plugins using the `amendLibrary` (Eleventy >= 2.0) or [`setLibrary` (Eleventy <= 1.0)](https://v1-0-2.11ty.dev/docs/languages/markdown/#add-your-own-plugins) Configuration API methods (building on the method described in “Options” above). 1. Find your [own `markdown-it` plugin on NPM](https://www.npmjs.com/search?q=keywords:markdown-it-plugin) 2. `npm install` the plugin. {%- set codeBlock %} import { full as emoji } from "markdown-it-emoji"; export default function (eleventyConfig) { eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(emoji)); }; {%- endset %} {{ codeBlock | highlight("js") | safe }} ## Indented Code Blocks Markdown has a lesser known feature called [Indented Code Blocks](https://spec.commonmark.org/0.28/#indented-code-blocks), which means any content that is indented by four or more spaces (and has a preceding line break) will be transformed into a code block. ```markdown a simple indented code block ``` is transformed into: ```html
a simple
indented code block
```
_(Example borrowed from the [CommonMark Specification](https://spec.commonmark.org/0.28/#indented-code-blocks))_
After [listening to community feedback](https://github.com/11ty/eleventy/issues/2438), starting with Eleventy 2.0.0 Indented Code Blocks are disabled for both the default Markdown library instance _and_ any set via `setLibrary`.