Eleventy is a great static site generator and one of the best parts of it is The Data Cascade. It's a notably simple way to map data to templates and I mean that in the best possible Simple Made Easy sense. I hope more static site generators steal it.
I wrote this document because I always need to look it up when I come back to Eleventy after a bit. I intend for this summary to help me re-remember by showing the patterns and structure of The Data Cascade all in one place.
In ascending order of precedence:
Global Data Directory:
|Scope:||In all templates|
|Examples:||Site-wide data such as API keys, header/footer inputs.|
|Scope:||All templates in directory or subdirectories if not overridden|
|Examples:||Section specific overrides like a new default layout, or section specific data to subsequently dynamically generate pages from.|
Template Data File
|Examples:||This data is the input for this page. Similar to input props for a component or database information for a server rendered page.|
|Examples:||Presentational properties to override, such as a layout specific page title.|
|Examples:||More common for this to be metadata about this page to be used in listing pages.|
The data keys are shallow merged via object assign.
I hope you find it useful!