Stand with Ukraine 🇺🇦
The possum is Eleventy’s mascot

Eleventy Documentation

This is an older version of Eleventy. Go to the newest Eleventy docs (current path: /docs/data-template-dir/) or the full release history.

Template and Directory Specific Data Files Jump to heading


While you can provide global data files to supply data to all of your templates, you may want some of your data to be available locally only to one specific template or to a directory of templates. For that use, we also search for JSON and JavaScript Data Files in specific places in your directory structure.

For example, consider a template located at posts/subdir/ Eleventy will look for data in the following places (starting with highest priority, local data keys override global data):

  1. Content Template Front Matter Data
  2. Template Data File (data is only applied to posts/subdir/
    • posts/subdir/my-first-blog-post.11tydata.js JavaScript Data Files
    • posts/subdir/my-first-blog-post.11tydata.json
    • posts/subdir/my-first-blog-post.json
  3. Directory Data File (data applies to all templates in posts/subdir/*)
    • posts/subdir/subdir.11tydata.js JavaScript Data Files
    • posts/subdir/subdir.11tydata.json
    • posts/subdir/subdir.json
  4. Parent Directory Data File (data applies to all templates in posts/**/*, including subdirectories)
  5. Global Data Files in _data/* (.js or .json files) available to all templates.

Examples Jump to heading

Apply a default layout to multiple templates Jump to heading

Filename posts/posts.json
{ "layout": "layouts/post.njk" }

Using the above in posts/posts.json will configure a layout for all of the templates inside of posts/*.

Additional Customizations Jump to heading

Sources of Data Jump to heading

When the data is merged in the Eleventy Data Cascade, the order of priority for sources of data is (from highest priority to lowest):

  1. Computed Data
  2. Front Matter Data in a Template
  3. Front Matter Data in Layouts (only in 0.x)
  4. Template Data Files
  5. Directory Data Files (and ascending Parent Directories)
  6. Front Matter Data in Layouts (moved in 1.0)
  7. Configuration API Global Data
  8. Global Data Files

Other pages in Data Cascade: