Skip to content

Latest commit

 

History

History
23 lines (13 loc) · 2.38 KB

README.md

File metadata and controls

23 lines (13 loc) · 2.38 KB

eleventy-Blog/_data

In Eleventy, the data directory is meant for global data, making them available to all templates via Eleventy’s data object.

See the Eleventy documentation for more information about the data cascade.

This directory shows one way to organize global data into modular files, like a typical blog. The site.js file here defines, among other items, a defaultLocale property as well as an en object which contains strings of text and other options specific to English-language content. You can edit the values for these properties to fit your site.

To change the main locale for your content, rename the en object key to another ISO language code and make the same change to the locale property in ../content/content.11tydata.js..

To add support for multiple content languages:

  1. Copy and paste the en object within site.js
  2. Renaming the copied object key to whatever ISO language code you choose, e.g., es for Spanish)
  3. Translate the values for each of the properties

See ../content/README.md to help you decide how to organize your multilingual content.

You don´t have to store all the global translation strings in site.js either. Instead, you could follow the pattern of assigning translation strings to language-code objects and create any number of JavaScript or JSON files in this directory.

Warning: Use camelCase to name new global data files. Don’t use hyphens (-). That way you can access their properties from the data object using JavaScript dot notation.

For example, you could create a file in this directory named siteFooter.js to store translation strings (along with any other data you like) that you want to target in a specific way in the ../_includes/shortcodes/site-footer.js shortcode. Or, you could create a file named branding.js to store localized references to your branding assets.