Files processed by 11ty can begin with front matter. This starts with a line containing three dashes and ends with the same kind of line. Lines between these define variables. Variables can be used in this and other files and can represent many kinds of values including text, numbers, URLs, CSS property values, icons, …
By default front matter is treated as YAML syntax. For example:
---
layout: topic-layout.njk
title: Dogs
---
To use JavaScript syntax instead, add js after the opening dashes.
For example:
---js
{
layout: 'layout.njk',
title: 'Dogs'
}
---
Some special variables recognized by 11ty include:
layout: uses a layout template found in the_includesdirectorytags: single string or array of collection names to which this data belongsdate: overrides the default file creation date to change sort orderpagination: enables iteration over data in front matter to output multiple HTML files from this templatepermalink: changes the output target of the templatedynamicPermalink: enables or disables template syntax in permalink values (default is true)templateEngineOverride: overrides the template engine used for this fileeleventyExcludeFromCollections: true to exclude this content from collections
TODO: Are there any Nunjucks-specific variables? TODO: See your front matter question at TODO: https://github.com/11ty/eleventy/issues/916#issuecomment-583764086.