We The Protesters
Eleventy
The possum is Eleventy’s mascot
Eleventy Documentation
Menu
Eleventy 1.93s
Astro 22.90s

Global Data File Preprocessing

ERROR:
Feature Removal: This feature was removed in Eleventy 2.0. You can use JavaScript Data Files or Computed Data instead.

The dir.data global data files run through this template engine before transforming to JSON. Read more about Global Data Files.

Data Template Engine
Object Key dataTemplateEngine
Default "liquid" (before 1.0)
Default false (1.0 and above)
Valid Options A valid template engine short name or false
Command Line Override None

Global JSON data files (not template/directory data files) can be optionally preprocessed with a template engine specified under the dataTemplateEngine configuration option.

Example Jump to heading

Filename .eleventy.js
module.exports = function(eleventyConfig) {
return {
"dataTemplateEngine": "njk"
}
};

For example, if your dataTemplateEngine is using njk or liquid you can do this in any *.json files in your _data folder:

Filename _data/myfile.json
{
"version": "{{ pkg.version }}"
}

package.json data is available here supplied by Eleventy in the pkg variable.