Eleventy Documentation

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

Documentation Pages

Template and Directory Specific Data Files #

While it is useful to have globally available 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 data files in specific places in your directory structure.

Important exception: Template and Directory Specific Data Files are not processed through a templating engine. Global Data files are.

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

  1. posts/subdir/my-first-blog-post.json (data only applied to posts/my-first-blog-post.md)
  2. posts/subdir/subdir.json (on all templates in posts/subdir/*)
  3. posts/posts.json (on all templates in posts/**/*, including subdirectories)
  4. _data/* (global data files available to all templates)

(Changed in Eleventy v0.2.15 to search parent directories for data files—specifically step 3 above was added in the sequence)

Apply a default layout to multiple templates #

Try adding { "layout": "layouts/post.njk" } to posts/posts.json to configure a layout for all of the templates inside of posts/*.