Eleventy The possum is Eleventy’s mascot

Eleventy Documentation

This is an older version of Eleventy. Go to the newest Eleventy docs (current path: /docs/advanced-order/) or the full release history.

Order of Operations #

From a very high level, Eleventy’s internal order of operations is such:

  1. Find any file matching a valid Eleventy file extension in the Input directory. (e.g. ./src/**.njk or ./docs/**.md)
  2. Iterate over the files.
    1. If it doesn’t match a template file extension, treat it as a passthrough copy.
    2. If it does match a template file extension, continue processing as an Eleventy template.
  3. Start the asynchronous copy of passthrough copy. Both configuration specified passthrough copy and non-template-matching file extension files. This will continue while templates are being processed.
  4. Initial Data Cascade is generated for each template file. This includes all values from front matter, layouts, directory and file data files, global data.
    • The data cascade does not yet include populated collections, templateContent, or computed page values like page.url and page.outputPath.
  5. Dependency graph is created of the templates to process them in the correct order.
    • This is a bit oversimplified (and some may mix and match if they aren’t dependent on each other) but from a high level the templates are processed like this (listed here in reverse order1 is processed first):
      1. Templates that use Pagination and target collections.all
      2. Templates that use Pagination and target collections
      3. Templates that use Pagination and target a Configuration API added collection
      4. Templates that use Pagination and target any other Collection (those supplied via tags)
      5. Templates that have tags specified
      6. Templates that have no dependencies or are eleventyExcludeFromCollections
    • Note: Eleventy does not automatically know what data is used inside of the template content at this stage. We use the specified front matter to know which templates supply collections and which templates consume collections. For a safety net we may add a front matter option to declare dependencies manually.
  6. Collections are generated in the correct order, per the dependency graph.
  7. Additional Data Cascade operations are applied:
  8. Templates are rendered in the order generated by the dependency graph (templateContent is generated) without layouts applied.
    1. Per the above Note if a template uses another template’s templateContent before it has been generated, we defer this template to render in a second pass.
    2. After all templateContent’s have been rendered, they are copied into the appropriate collections’ objects. Remember that templateContent in collections does not have layouts included.
  9. Eleventy checks for duplicate permalinks and throws an error if multiple templates are attempting to write to the same output file.
  10. Templates are then rendered with layouts applied. The previously generated templateContent values (without layouts) are re-used here. This content is then written to files on disk.