Logo

Data Cascade

When Sissi processes a template it merges data from three sources, in order of increasing precedence:

  1. Sissi built-ins — the page object, collections, and anything provided by plugins
  2. _data/ files — global data loaded from your data directory
  3. Frontmatter — per-file data declared at the top of each source file

Later sources win, so frontmatter values override global data, and global data overrides Sissi defaults.

Data provided by Sissi

Every template receives a page object describing the current file:

FieldExampleDescription
page.url/posts/hello/Output URL path
page.inputPathposts/hello.mdSource file path (relative to input dir)
page.outputPathpublic/posts/hello/index.htmlAbsolute output file path
page.fileSlughelloFilename without extension
page.filePathStem/posts/helloPath without extension
page.outputFileExtensionhtmlExtension of the output file
page.dateDate objectDate from frontmatter, or epoch if absent
<a href="{{ page.url }}">Permalink</a>

The _data subdirectory

Any .js, .json, or .yaml file in _data/ is loaded as global data. The filename (without extension) becomes the key:

JavaScript — the default export is the value; it can be a plain object, an array, or an async function:

// _data/meta.js
export default {
  author: 'Lea Rosema',
  siteTitle: 'My Site',
};

JSON:

// _data/links.json
[
  { "label": "GitHub", "url": "https://github.com" }
]

YAML:

# _data/nav.yaml
- label: Home
  url: /
- label: About
  url: /about/

All three are accessed in templates by their filename stem:

{{ meta.author }}
{{ meta.siteTitle }}

Changes to any file in _data/ trigger a full site rebuild in watch mode.

The Frontmatter

Frontmatter is declared at the very top of a source file between --- delimiters. YAML is the default format:

---
title: Hello World
date: 2024-06-01
tags: [post, featured]
layout: base.html
---

You can also use JSON by writing ---json as the opening delimiter:

---json
{
  "title": "Hello World",
  "tags": ["post", "featured"],
  "layout": "base.html"
}
---

Reserved frontmatter keys

KeyEffect
layoutWraps the page in a layout from _layouts/
tagsAdds the page to one or more collections
dateSets the page date used for sorting
eleventyExcludeFromCollectionstrue to exclude from all collections, or a list of tag names to exclude from specific ones

Using data inside templates

See the Templating page for the full template syntax. A quick example:

If _data/meta.js exports { author: 'Lea' }, you can reference it as:

{{ meta.author }}

If the value resolves to a function it is called with no arguments. If it returns a Promise it is awaited automatically.