Documentation Pages
Template and Directory Specific Data Files #
Added in Eleventy 0.2.14
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):
posts/subdir/my-first-blog-post.json
(data only applied toposts/my-first-blog-post.md
)posts/subdir/subdir.json
(on all templates inposts/subdir/*
)posts/posts.json
(on all templates inposts/**/*
, including subdirectories)_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/*
.