Diagnosing Missing Global Data in Eleventy Templates
A diagnostic guide for when Eleventy global data files in _data don't appear in templates—covering recognizable symptoms, a cause table, ordered checks, targeted fixes, and escalation steps.
26 Jan 2026, 02:46 UTC

The Problem
Your Eleventy build completes without errors, but templates render with empty or undefined variables where global data should appear. The generated HTML lacks content that depends on files in the _data directory—no error messages, just missing output.
Quick Diagnostic Table
| Symptom | Likely Cause |
|---|---|
Variable is undefined in template | Data file not in _data folder, or filename doesn't match variable name |
| Variable exists but is empty object | Invalid JSON/JS syntax, or async function not returning resolved data |
| Wrong data appears | Key collision across multiple data files overriding values |
| Data works locally but not in CI | Eleventy version mismatch (pre-0.11 behavior differs) |
Ordered Checks
- Confirm
_datalocation. The directory must sit at the project root (same level as.eleventy.jsorpackage.json). Runls -la _data/from the project root to verify. - Match filename to variable. Eleventy maps
_data/site.jsonto thesitevariable. If your template uses{{ site.title }}, the file must be namedsite.json(orsite.js,site.11tydata.js). - Validate file content. For JSON: run
cat _data/site.json | jq .to catch syntax errors. For JS modules: ensure the file exports an object or a function returning an object/promise. - Check async data resolution. A JS data file exporting
async function() { return fetch(...).then(r => r.json()) }works; exportingfetch(...).then(...)withoutreturnorawaityields empty data silently. - Search for key collisions. If
_data/site.jsonand_data/config.jsonboth export atitlekey, the last-loaded file wins. Runeleventy --debugand inspect the[Eleventy] Global Datalog section to see merge order. - Verify Eleventy version. Run
npx @11ty/eleventy --version. Versions before 0.11 handled global data differently; upgrade withnpm install @11ty/eleventy@latestif needed.
Fixes Tied to Findings
Misplaced or misnamed file
Move the file into _data/ and rename to match the template variable. Example: a file at src/data/meta.json used as {{ meta }} in templates must become _data/meta.json.
Syntax error in data file
Correct JSON (trailing commas, unquoted keys) or JS (missing module.exports, syntax errors). A minimal valid JS data file:
// _data/site.11tydata.js
module.exports = {
title: "My Site",
url: "https://example.com"
};
Async data not resolving
Ensure the exported function returns the promise or uses await at the top level (requires .11tydata.js extension):
// _data/posts.11tydata.js
module.exports = async function() {
const res = await fetch('https://api.example.com/posts');
return res.json();
};
Without return or await, Eleventy receives a pending promise and treats it as empty data.
Key collision
Rename conflicting keys (e.g., siteTitle vs configTitle) or consolidate into a single data file. Use eleventy --debug to confirm load order.
Version upgrade and cache clear
After upgrading Eleventy, clear the cache and rebuild:
rm -rf .eleventy_cache
npx @11ty/eleventy
Run this from the project root with write permissions to the working directory.
Escalation Criteria
If data still doesn't appear after all checks:
- Disable plugins one by one in
.eleventy.jsto isolate interference. - Inspect
.eleventy.jsfor customaddGlobalDatacalls or data cascade overrides that may shadow_datafiles. - Check for middleware (e.g., in Eleventy Edge or serverless adapters) that strips data before rendering.
- Create a minimal reproducible repository: a fresh Eleventy project with one
_data/test.jsonand one template using{{ test }}. If the issue persists, open an issue on Eleventy's GitHub with that reproduction.
Verification Steps
Create a minimal test to confirm the diagnostic flow works:
mkdir test-eleventy-data && cd test-eleventy-datanpm init -y && npm install @11ty/eleventymkdir _data _includes- Create
_data/site.json:{"title": "Test Site"} - Create
_includes/base.njk:<h1>{{ site.title }}</h1> - Create
index.njkwith front matter:--- layout: base.njk --- - Run
npx @11ty/eleventyand check_site/index.htmlcontains<h1>Test Site</h1>. - Rename
_data/site.jsonto_data/data.json, rebuild, and verify{{ site.title }}renders empty. - Restore the name, rebuild, and confirm output returns.
Limitations
- This guide covers global data files only. Template/directory data files (e.g.,
posts.11tydata.jsonalongsideposts/) follow different scoping rules. - Custom data extensions via
config.addDataExtension()may introduce additional failure modes not covered here. - Eleventy 3.0 (when released) may change data cascade behavior; verify against the version in use.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.