Files
Lucien Bill d8055c62b6 fix typo
2023-06-12 08:54:16 +00:00
..
2023-05-22 23:18:26 +02:00
2023-06-12 08:54:16 +00:00
2023-05-30 16:01:13 +02:00
2023-06-07 16:11:26 +02:00
2022-12-15 07:58:02 +00:00
2021-12-03 14:05:19 +01:00
2022-02-09 09:20:15 +01:00
2023-05-23 10:40:12 +02:00

eleventy-dot-js-blog/content

By default, Eleventy works with your projects existing directory structure. Unlike other static site generators, Eleventy lets you choose how to organize your content.

This directory shows one way to organize content into pages and posts, like a typical blog. If you wanted to use this project to publish an e-book, you might use directories for each of the parts and chapters. Or, if you wanted to make a glossary, you might use directories for each letter of the alphabet.

The content.11tydata.js file here defines directory data, accessible in templates via the data object. For example, because content.11tydata.js defines a locale property, all the templates in this directory as well as any directories nested inside this one will inherit that data.locale value (i.e., en for English). You can override that “default” value by specifying a new locale value in either a template data file or the front matter data for a given template.

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

To carry the data.locale example further, this directory structure also allows you to add support for internationalization (i18n) and localization (l10n).

Heres an example of one way you might go about adding Spanish-language content:

  1. Make a directory named es inside this one (optionally, you could move all existing English-language content into a new en directory too)
  2. Nest corresponding copies of the pages and posts directories inside the newly created es directory (e.g., content/es/pages and content/es/posts)
  3. Copy content.11tydata.js to the es directory, and rename the copied file es.11tydata.js
  4. Do the same for content/es/pages/pages.11tydata.js and content/es/posts/posts.11tydata.js
  5. Copy content/index.md (the blog home page) to content/es/index.md and set permalink to '/es/' in the front matter data
  6. Add an identical front matter data property to each of the multilingual content files (dont translate the value, e.g., add translationKey: 'about' in the front matter for both pages/about.md and es/pages/about.md, or translationKey: 'home' inside both contect/index.md and content/es/index.md)

See ../_data/README.md for instructions on how to translate global data strings.

For a discussion of how a multilingual setup like this might work (using Nunjucks templates), check out Jérôme Coupés pair of blog posts from 2019 on “Multilingual Sites with Eleventy” and prototype for a “Language switcher for multilingual JAMstack sites”.