11ty

Eleventy Documentation

This documentation is for an older version. Go to the newest Eleventy docs or check out the full release history.

Documentation Pages

Using Data #

Data can be used on a template from multiple different sources.

Sources of Data #

The order of priority for sources of data is (from highest priority to lowest):

  1. Front Matter Data
  2. Template Data Files
  3. Directory Data Files (and ascending Parent Directories)
  4. Global Data Files

Eleventy Provided Data Variables #

Here are a few data values we supply to your page that you can use in your templates:

page Variable Contents: #

let page = {
// URL can be used in <a href> to link to other templates
url: "/current/page/myFile/",
// New in Eleventy v0.3.4
// Mapped from inputPath, useful for permalinks
fileSlug: "myFile",
// JS Date Object for current page (used to sort collections)
date: new Date(),
// The path to the original source file for the template
// Note: this will include your input directory path!
inputPath: "./current/page/myFile.md",
// Eleventy internals
// You probably won’t use `outputPath`: `url` is more useful.
// Depends on your output directory (the default is _site)
outputPath: "./_site/current/page/myFile/index.html"
};

fileSlug #

New in v0.3.4 The fileSlug variable is mapped from inputPath and is useful for creating your own clean permalinks.

inputPathResulting fileSlug
"2018-01-01-myFile.md""myFile"
"myDir/myFile.md""myFile"

fileSlug returns information on the parent directory if the file is an index template:

inputPathResulting fileSlug
"index.md""" (empty)
"myDir/index.md""myDir"
"myDir/2018-01-01-index.md""myDir"

date #

The date associated with the page. Defaults to the content’s file created date but can be overridden. Read more at Content Dates.