Global Data Files and Configuration

**Referenced Files in This Document** - [.eleventy.js](file://.eleventy.js) - [src/_data/site.json](file://src/_data/site.json) - [src/_data/pages.json](file://src/_data/pages.json) - [src/_data/homepage.json](file://src/_data/homepage.json) - [src/_data/about.json](file://src/_data/about.json) - [src/_data/testimonials.json](file://src/_data/testimonials.json) - [src/_data/partners.json](file://src/_data/partners.json) - [src/_data/affiliations.json](file://src/_data/affiliations.json) - [src/_data/allianceMembers.json](file://src/_data/allianceMembers.json) - [src/_data/polling.js](file://src/_data/polling.js) - [src/content/cases/cases.11tydata.json](file://src/content/cases/cases.11tydata.json) - [src/content/news/news.11tydata.json](file://src/content/news/news.11tydata.json) - [src/content/services/services.11tydata.json](file://src/content/services/services.11tydata.json) - [src/content/team/team.11tydata.json](file://src/content/team/team.11tydata.json) - [src/content/knowledge/knowledge.11tydata.js](file://src/content/knowledge/knowledge.11tydata.js)

Table of Contents

  1. Introduction
  2. Project Structure
  3. Core Components
  4. Architecture Overview
  5. Detailed Component Analysis
  6. Dependency Analysis
  7. Performance Considerations
  8. Troubleshooting Guide
  9. Conclusion
  10. Appendices

Introduction

This document explains Eleventy’s global data system in this project, focusing on how files in src/_data/ are processed and exposed globally, how site-wide and page-specific data are organized, and how dynamic data is loaded. It also covers data file naming conventions, JSON parsing, data merging strategies, environment-specific configurations, caching, validation, error handling, and performance optimization for large configuration files. Practical guidance is included for organizing data hierarchies and implementing data-driven content generation.

Project Structure

Eleventy’s configuration defines the data directory and other directories. The global data files live under src/_data/, while page-specific data is defined via 11ty data files alongside content. The build pipeline watches src/_data/ for changes to refresh the site during development.

Key configuration highlights:

  • Data directory is set to "_data" under the input directory.
  • Passthrough copy includes static assets and admin resources.
  • Watch targets include src/assets, src/assets/css, src/assets/js, and src/_data/.
graph TB
A[".eleventy.js<br/>dir.data = '_data'"] --> B["src/_data/<br/>Global data files"]
B --> C["JSON files<br/>site.json, pages.json, homepage.json,<br/>about.json, testimonials.json,<br/>partners.json, affiliations.json,<br/>allianceMembers.json"]
B --> D["JS files<br/>polling.js"]
E["Content with 11ty data<br/>cases.11tydata.json,<br/>news.11tydata.json,<br/>services.11tydata.json,<br/>team.11tydata.json,<br/>knowledge.11tydata.js"] --> F["Per-content data merges<br/>with global data"]

Diagram sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)

Section sources

  • [.eleventy.js:19-21](file://.eleventy.js#L19-L21)
  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)

Core Components

  • Global data directory: src/_data/ is the root for global data files. Eleventy loads all JSON and JS files here and exposes their exports under a single global namespace for templates.
  • Page-specific data: Content directories can include 11ty data files (JSON or JS) to customize front matter, permalinks, layouts, and computed values per content type or page.
  • Dynamic data: JavaScript files in src/_data/ can export async functions to compute runtime data (e.g., polling results).
  • Site configuration: site.json centralizes metadata like title, description, URL, social links, and contact info.
  • Page hero and CTAs: pages.json organizes hero and call-to-action content per page.
  • Homepage content: homepage.json defines homepage-specific sections and CTAs.
  • About page content: about.json structures hero, bios, values, and testimonials-related blocks.
  • Testimonials, partners, affiliations: structured lists for testimonials, partner logos, and professional affiliations.
  • Alliance members: allianceMembers.json defines member portal content and dashboard tiles.
  • Polling data: polling.js computes and exposes polling metrics with a fallback flag.

Section sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)
  • [src/_data/site.json:1-20](file://src/_data/site.json#L1-L20)
  • [src/_data/pages.json:1-79](file://src/_data/pages.json#L1-L79)
  • [src/_data/homepage.json:1-23](file://src/_data/homepage.json#L1-L23)
  • [src/_data/about.json:1-102](file://src/_data/about.json#L1-L102)
  • [src/_data/testimonials.json:1-24](file://src/_data/testimonials.json#L1-L24)
  • [src/_data/partners.json:1-14](file://src/_data/partners.json#L1-L14)
  • [src/_data/affiliations.json:1-12](file://src/_data/affiliations.json#L1-L12)
  • [src/_data/allianceMembers.json:1-40](file://src/_data/allianceMembers.json#L1-L40)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Architecture Overview

The global data system integrates:

  • Global data loading from src/_data/ into a unified namespace.
  • Per-content data merging from 11ty data files alongside content.
  • Template rendering using Nunjucks with access to merged data.
graph TB
subgraph "Eleventy Config"
EC[".eleventy.js<br/>dir.data = '_data'<br/>addWatchTarget('src/_data/')"]
end
subgraph "Global Data"
GD1["site.json"]
GD2["pages.json"]
GD3["homepage.json"]
GD4["about.json"]
GD5["testimonials.json"]
GD6["partners.json"]
GD7["affiliations.json"]
GD8["allianceMembers.json"]
GD9["polling.js"]
end
subgraph "Content with 11ty Data"
CD1["cases.11tydata.json"]
CD2["news.11tydata.json"]
CD3["services.11tydata.json"]
CD4["team.11tydata.json"]
CD5["knowledge.11tydata.js"]
end
EC --> GD1
EC --> GD2
EC --> GD3
EC --> GD4
EC --> GD5
EC --> GD6
EC --> GD7
EC --> GD8
EC --> GD9
CD1 --> EC
CD2 --> EC
CD3 --> EC
CD4 --> EC
CD5 --> EC

Diagram sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)
  • [src/_data/site.json:1-20](file://src/_data/site.json#L1-L20)
  • [src/_data/pages.json:1-79](file://src/_data/pages.json#L1-L79)
  • [src/_data/homepage.json:1-23](file://src/_data/homepage.json#L1-L23)
  • [src/_data/about.json:1-102](file://src/_data/about.json#L1-L102)
  • [src/_data/testimonials.json:1-24](file://src/_data/testimonials.json#L1-L24)
  • [src/_data/partners.json:1-14](file://src/_data/partners.json#L1-L14)
  • [src/_data/affiliations.json:1-12](file://src/_data/affiliations.json#L1-L12)
  • [src/_data/allianceMembers.json:1-40](file://src/_data/allianceMembers.json#L1-L40)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)
  • [src/content/cases/cases.11tydata.json:1-2](file://src/content/cases/cases.11tydata.json#L1-L2)
  • [src/content/news/news.11tydata.json:1-2](file://src/content/news/news.11tydata.json#L1-L2)
  • [src/content/services/services.11tydata.json:1-2](file://src/content/services/services.11tydata.json#L1-L2)
  • [src/content/team/team.11tydata.json:1-2](file://src/content/team/team.11tydata.json#L1-L2)
  • [src/content/knowledge/knowledge.11tydata.js:1-8](file://src/content/knowledge/knowledge.11tydata.js#L1-L8)

Detailed Component Analysis

Global Data Loading and Merging

  • JSON files: Eleventy parses JSON files in src/_data/ and merges them into a single global namespace. Keys from each file become top-level keys available in templates.
  • JS files: Eleventy executes JS files exporting either a plain object or an async function returning an object. Async functions enable dynamic computation and external data fetching.
  • Data precedence: Per-content 11ty data files override or merge with global data depending on the property. Eleventy merges content front matter and 11ty data into the final data object passed to templates.
flowchart TD
Start(["Build Start"]) --> LoadGlobal["Load JSON and JS from src/_data/"]
LoadGlobal --> MergeGlobal["Merge into global data namespace"]
MergeGlobal --> LoadContent["Load content files and 11ty data files"]
LoadContent --> MergeContent["Merge content front matter and 11ty data"]
MergeContent --> FinalData["Final data for templates"]
FinalData --> Render["Render templates with merged data"]
Render --> End(["Build Complete"])

[No sources needed since this diagram shows conceptual workflow, not actual code structure]

Section sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Data File Naming Conventions and Organization

  • JSON naming: Use descriptive names that reflect the domain (e.g., site.json, pages.json, homepage.json, about.json, testimonials.json, partners.json, affiliations.json, allianceMembers.json).
  • JS naming: Use descriptive names for dynamic data (e.g., polling.js).
  • 11ty data files: Place 11ty data files adjacent to content (e.g., cases.11tydata.json, news.11tydata.json, services.11tydata.json, team.11tydata.json, knowledge.11tydata.js) to keep per-content overrides close to content.

Section sources

  • [src/_data/site.json:1-20](file://src/_data/site.json#L1-L20)
  • [src/_data/pages.json:1-79](file://src/_data/pages.json#L1-L79)
  • [src/_data/homepage.json:1-23](file://src/_data/homepage.json#L1-L23)
  • [src/_data/about.json:1-102](file://src/_data/about.json#L1-L102)
  • [src/_data/testimonials.json:1-24](file://src/_data/testimonials.json#L1-L24)
  • [src/_data/partners.json:1-14](file://src/_data/partners.json#L1-L14)
  • [src/_data/affiliations.json:1-12](file://src/_data/affiliations.json#L1-L12)
  • [src/_data/allianceMembers.json:1-40](file://src/_data/allianceMembers.json#L1-L40)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)
  • [src/content/cases/cases.11tydata.json:1-2](file://src/content/cases/cases.11tydata.json#L1-L2)
  • [src/content/news/news.11tydata.json:1-2](file://src/content/news/news.11tydata.json#L1-L2)
  • [src/content/services/services.11tydata.json:1-2](file://src/content/services/services.11tydata.json#L1-L2)
  • [src/content/team/team.11tydata.json:1-2](file://src/content/team/team.11tydata.json#L1-L2)
  • [src/content/knowledge/knowledge.11tydata.js:1-8](file://src/content/knowledge/knowledge.11tydata.js#L1-L8)

Site Configuration and Global Metadata

  • site.json centralizes site-wide metadata such as title, description, URL, language, contact details, ABN, social links, and form identifiers. Templates can reference these values globally.

Section sources

  • [src/_data/site.json:1-20](file://src/_data/site.json#L1-L20)

Page-Specific Hero and CTA Content

  • pages.json organizes hero and CTA content per page (team, cases, news, contact, newsletters). This enables consistent reuse of page-level content across templates.

Section sources

  • [src/_data/pages.json:1-79](file://src/_data/pages.json#L1-L79)

Homepage Content Blocks

  • homepage.json defines homepage-specific labels, headings, and CTAs for sections such as capabilities, testimonials, team, news, affiliations, and CTAs.

Section sources

  • [src/_data/homepage.json:1-23](file://src/_data/homepage.json#L1-L23)

About Page Content

  • about.json structures hero content, biography paragraphs, mosaic imagery, diplomatic and technical expertise, values, film frames, accordion items, and CTAs.

Section sources

  • [src/_data/about.json:1-102](file://src/_data/about.json#L1-L102)

Lists and Media Assets

  • testimonials.json: array of testimonials with quote, author, and role.
  • partners.json: array of partner logos with filenames and alt text.
  • affiliations.json: array of affiliation logos with filenames and alt text.
  • allianceMembers.json: member portal hero, welcome message, dashboard tiles, and recent resources.

Section sources

  • [src/_data/testimonials.json:1-24](file://src/_data/testimonials.json#L1-L24)
  • [src/_data/partners.json:1-14](file://src/_data/partners.json#L1-L14)
  • [src/_data/affiliations.json:1-12](file://src/_data/affiliations.json#L1-L12)
  • [src/_data/allianceMembers.json:1-40](file://src/_data/allianceMembers.json#L1-L40)

Dynamic Data Loading (Polling)

  • polling.js exports an async function that returns computed polling metrics and a fallback flag. This pattern supports runtime computation and can integrate with external APIs or databases.
sequenceDiagram
participant Eleventy as "Eleventy Engine"
participant DataFile as "src/_data/polling.js"
participant Template as "Nunjucks Template"
Eleventy->>DataFile : Execute module.exports()
DataFile-->>Eleventy : Promise resolved object
Eleventy->>Template : Expose merged data (including polling)
Template-->>Template : Render with polling metrics

Diagram sources

  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Section sources

  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Page-Specific Data Overrides

  • cases.11tydata.json disables permalinks for the cases collection.
  • news.11tydata.json disables permalinks for the news collection.
  • services.11tydata.json disables permalinks for the services collection.
  • team.11tydata.json disables permalinks for the team collection.
  • knowledge.11tydata.js sets a custom layout and tag, and computes a permalink based on the page slug.
sequenceDiagram
participant Eleventy as "Eleventy Engine"
participant CasesData as "cases.11tydata.json"
participant NewsData as "news.11tydata.json"
participant ServicesData as "services.11tydata.json"
participant TeamData as "team.11tydata.json"
participant KnowledgeData as "knowledge.11tydata.js"
Eleventy->>CasesData : Merge front matter and computed data
Eleventy->>NewsData : Merge front matter and computed data
Eleventy->>ServicesData : Merge front matter and computed data
Eleventy->>TeamData : Merge front matter and computed data
Eleventy->>KnowledgeData : Merge front matter and computed data
Eleventy-->>Eleventy : Final per-content data ready for templates

Diagram sources

  • [src/content/cases/cases.11tydata.json:1-2](file://src/content/cases/cases.11tydata.json#L1-L2)
  • [src/content/news/news.11tydata.json:1-2](file://src/content/news/news.11tydata.json#L1-L2)
  • [src/content/services/services.11tydata.json:1-2](file://src/content/services/services.11tydata.json#L1-L2)
  • [src/content/team/team.11tydata.json:1-2](file://src/content/team/team.11tydata.json#L1-L2)
  • [src/content/knowledge/knowledge.11tydata.js:1-8](file://src/content/knowledge/knowledge.11tydata.js#L1-L8)

Section sources

  • [src/content/cases/cases.11tydata.json:1-2](file://src/content/cases/cases.11tydata.json#L1-L2)
  • [src/content/news/news.11tydata.json:1-2](file://src/content/news/news.11tydata.json#L1-L2)
  • [src/content/services/services.11tydata.json:1-2](file://src/content/services/services.11tydata.json#L1-L2)
  • [src/content/team/team.11tydata.json:1-2](file://src/content/team/team.11tydata.json#L1-L2)
  • [src/content/knowledge/knowledge.11tydata.js:1-8](file://src/content/knowledge/knowledge.11tydata.js#L1-L8)

Environment-Specific Configurations

  • Environment detection: The configuration checks NODE_ENV to conditionally enable HTML minification transforms in production.
  • Data-level environment logic: Add environment-specific branches inside JS data files (e.g., polling.js) to switch behavior based on environment variables.

Section sources

  • [.eleventy.js:242-261](file://.eleventy.js#L242-L261)

Data Validation and Error Handling

  • JSON parsing: Eleventy validates JSON files; malformed JSON will cause build errors. Keep indentation and commas consistent.
  • JS data errors: Unhandled rejections in async data loaders will fail the build. Wrap async logic with try/catch and provide fallbacks (e.g., _fallback flag in polling.js).
  • Front matter validation: 11ty data files must be valid JSON or JS. Prefer explicit defaults and guard clauses in JS data files.

Section sources

  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Data Caching Mechanisms

  • Eleventy caches computed data during builds. To optimize performance:
    • Keep heavy computations in JS data files and memoize results when safe.
    • Use environment variables to toggle expensive operations in development vs. production.
    • Avoid unnecessary filesystem reads in data loaders.

[No sources needed since this section provides general guidance]

Performance Optimization for Large Configuration Files

  • Split large JSON files into smaller domain-focused files (e.g., site.json, pages.json, homepage.json).
  • Use JS data files for dynamic or computed data to avoid duplicating large static datasets.
  • Minimize nested arrays and objects; prefer flat structures where possible for easier iteration in templates.
  • Use Eleventy collections to pre-filter and sort content rather than doing heavy work in templates.

[No sources needed since this section provides general guidance]

Implementing Data-Driven Content Generation

  • Use global data for shared metadata and reusable content blocks.
  • Use per-content 11ty data files to tailor permalinks, layouts, and computed values.
  • Leverage eleventyComputed to derive URLs or other derived data from page metadata.

Section sources

  • [src/content/knowledge/knowledge.11tydata.js:1-8](file://src/content/knowledge/knowledge.11tydata.js#L1-L8)

Dependency Analysis

The global data system depends on:

  • Eleventy configuration to define the data directory and watch targets.
  • Global JSON and JS files in src/_data/.
  • Per-content 11ty data files to override or enrich global data.
graph LR
Config[".eleventy.js<br/>dir.data='_data'"] --> DataDir["src/_data/"]
DataDir --> Site["site.json"]
DataDir --> Pages["pages.json"]
DataDir --> Home["homepage.json"]
DataDir --> About["about.json"]
DataDir --> Testi["testimonials.json"]
DataDir --> Partners["partners.json"]
DataDir --> Affil["affiliations.json"]
DataDir --> Alliance["allianceMembers.json"]
DataDir --> Poll["polling.js"]
Content["Content + 11ty data files"] --> Merge["Merged data"]
Site --> Merge
Pages --> Merge
Home --> Merge
About --> Merge
Testi --> Merge
Partners --> Merge
Affil --> Merge
Alliance --> Merge
Poll --> Merge

Diagram sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)
  • [src/_data/site.json:1-20](file://src/_data/site.json#L1-L20)
  • [src/_data/pages.json:1-79](file://src/_data/pages.json#L1-L79)
  • [src/_data/homepage.json:1-23](file://src/_data/homepage.json#L1-L23)
  • [src/_data/about.json:1-102](file://src/_data/about.json#L1-L102)
  • [src/_data/testimonials.json:1-24](file://src/_data/testimonials.json#L1-L24)
  • [src/_data/partners.json:1-14](file://src/_data/partners.json#L1-L14)
  • [src/_data/affiliations.json:1-12](file://src/_data/affiliations.json#L1-L12)
  • [src/_data/allianceMembers.json:1-40](file://src/_data/allianceMembers.json#L1-L40)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Section sources

  • [.eleventy.js:267-283](file://.eleventy.js#L267-L283)

Performance Considerations

  • Keep global data files modular and focused to reduce memory footprint.
  • Use async data loaders sparingly and cache results when appropriate.
  • Avoid large binary blobs in JSON; prefer asset references and load assets via templates or shortcodes.
  • Use Eleventy filters and transforms judiciously; disable heavy transforms in development.

[No sources needed since this section provides general guidance]

Troubleshooting Guide

  • JSON parse errors: Verify syntax in JSON files. Use an editor with JSON validation.
  • Missing data in templates: Confirm the key exists in the global namespace and is not overridden unexpectedly by per-content 11ty data.
  • Async data failures: Ensure promises resolve and handle errors gracefully in JS data files.
  • Watch targets not triggering: Confirm src/_data/ is included in watch targets and changes are saved.

Section sources

  • [.eleventy.js:19-21](file://.eleventy.js#L19-L21)
  • [src/_data/polling.js:1-17](file://src/_data/polling.js#L1-L17)

Conclusion

This project demonstrates a clean separation of concerns for Eleventy’s global data system. Global data in src/_data/ provides shared metadata and reusable content blocks, while per-content 11ty data files tailor behavior and computed values. Dynamic data loaders enable runtime computation, and environment-aware logic supports flexible deployments. Following the naming conventions, validation practices, and performance recommendations outlined here will help maintain a scalable and robust data layer.

Appendices

  • Example data structures:
    • Site metadata: site.json
    • Page hero and CTAs: pages.json
    • Homepage sections: homepage.json
    • About content: about.json
    • Lists: testimonials.json, partners.json, affiliations.json
    • Member portal: allianceMembers.json
    • Dynamic metrics: polling.js
  • Per-content overrides:
    • cases.11tydata.json
    • news.11tydata.json
    • services.11tydata.json
    • team.11tydata.json
    • knowledge.11tydata.js

[No sources needed since this section aggregates previously cited files]