Templates and data
In your terminal ssqch docs "Templates and data"
The lay of the land:
The data cascade: a page's data comes from several places, and each one replaces what the ones before it set: global data, the front matter of its layouts, directory data, the page's data file, its front matter, then
computed. Where a value comes from has the exact order, andssqch traceshows it for any page.Collections: tags become collections, sorted by date, plus your custom ones.
excludeFromCollections: truekeeps a page out. A page for each tag: the blog starter (ssqch init) has atagListcollection in its config (each tag with its posts, newest first) andsrc/tag.jinja, which paginates over it withsize: 1andpermalink: /tags/{{ tag.name | slugify }}/, andsrc/tags.jinjalists them all (Tags and tag pages has the whole example).Pagination: one template makes a page for each item, or each group of items, in a list. In its front matter,
pagination: { data: "collections.posts", size: 10, alias: "posts" }and apermalinkwith the page number (/blog/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber + 1 }}/{% endif %}).datanames the list: global data (snacks), a collection (collections.posts, a custom collection included, even one that returns plain objects, so one template can write a page per route of a route table), orcollectionsitself, the collections' names, for a page per tag (filter: [all]leavesallout).size: 1gives a page per item, andaliasnames the item (alias: post, then{{ post.data.title }}). Each page getspagination.items(its items),pageNumber(from 0),pages(every page's items),hrefs(every page's URL),href.previous,href.next,href.firstandhref.last. More options:reverse,filter(values to leave out) andaddAllPagesToCollections(every page in the template's collections, not just the first). Acomputedvalue in a data file beside the template sees the alias, so each page's data can come from its item.Permalinks: dynamic permalinks,
permalink: falseanddynamicPermalink. A permalink (orcomputedvalue) with{{ }}renders in the page's own template language, so a Liquid page can writepermalink: "/{{ title | slugify }}/"; Markdown and HTML pages use theirmarkdownEngineorhtmlEngine(Edge when that'sfalse). A permalink orcomputedstring is data, not HTML, so nothing in it is escaped as it's worked out:title: "Tagged {{ tag.name }}"with a tagRock & RollisTagged Rock & Roll, and the layout that prints{{ title }}escapes it, once.Front matter: YAML between
---lines, TOML between+++lines, or JSON after---json(---yamland---tomlwork too)..markdownfiles are Markdown, like.md.Navigation:
navTree(nav, page.url)takes a tree from data (_data/nav.yml: entries withtitle,url, and children underchildren,itemsorpages) and marks each entrycurrent,ancestororopen, for a sidebar that highlights where you are. The marks follow the tree, not the URL: an entry isancestorwhen the page is among its children, so a flat menu's "Snacks" (/snacks/) isn't marked on/snacks/pine-cone-crunch/unless that page is in the tree under it. For a flat menu, compare the URL in the template instead:{% if page.url.startswith(item.url) and item.url != "/" %}(page.url.startsWith(item.url)in Edge and EJS).navPager(nav, page.url)returns{ previous, next }in reading order (a collection works as the tree too:navPager(collections.posts, page.url).nextis the next post, which is Eleventy'scollections.posts | getNextCollectionItem(page), and that andgetPreviousCollectionItemwork as they are), andnavBreadcrumbs(nav, page.url)the entries from the top down to the page. To build the tree from front matter instead, give pagesnav: { title, parent, order }(ornav: true) and usepagesTree(collections.docs): an entry's key is itsnav.key, or else its title;parentnames another entry's key, and aparentno page has becomes a heading (an entry with that title and nourl) holding its children. The title isnav.title, the page'stitle, ornav.key;nav.urlreplaces the page's URL (a link elsewhere), and any othernavkey (excerpt) is copied onto the entry.pagesTree(collections.all, { root: "Feature" })({{ collections.all | pagesTree: root: "Feature" }}in Liquid) is the tree below the keyFeature, page or heading, which is eleventy-navigation'seleventyNavigation: "Feature"; an unknown option is an error. URLs match with or withoutindex.htmland the last/.Components: a PascalCase tag in a page or a layout,
<TrailSchoolLink href="https://trails.example/lessons/x" title="Free lesson">Watch it</TrailSchoolLink>or<Badge type="tip" text="new" />, renders_includes/components/TrailSchoolLink.*in its place, a template in any engine, as VitePress, Astro and MDX pages use components. It gets the page's data andcomponent:component.name,component.props(each attribute:href="x"is"x", a baredisabledistrue, akebab-casename is there in camelCase too, and Vue's bindings are read against the page's data::text="title"is the page's title,:count="3"is 3,:items="['a', 'b']"a list; anything more is the expression as written),component.content(what's between its tags, as HTML, with the components inside it rendered: print it with| safe) andcomponent.attrs(the plain attributes as written,class="x" href="y", to put on the element the template writes). Vue's directives and events (v-if,@click,#title) are left out of both. The page's components render with its body, so its layouts andtemplateContentget the HTML, and a layout's own (<SiteFooter />) after the layouts. What's inside<pre>,<code>,<script>,<style>,<textarea>and comments isn't read, so a code sample's<Badge />stays text; HTML's names are lower case and SVG's camelCase ones start lower case, so only PascalCase tags are components, and a custom element (<trail-map>) has a hyphen. A PascalCase tag with no template is a warning that names the pages it's on (browsers would drop the tag and show what's inside it), and is left as written. A component with state (a counter, a REPL) needs JavaScript in the browser: a custom element fromssqch/elementsfor that part, or, for Vue's own.vuecomponents,vuePlugin()fromssqch/vue, which renders the tags_includes/components/has no template for, and withhydrateruns them in the browser too. A site's React components (.jsx, an MDX page's imports) render the same way withreactPlugin()fromssqch/react(React components).Dates: a page's
datecomes from its data, then from the start of its file name (2024-06-01-post.md), then from when the file last changed.computed.dateworks too. A date is2026-11-22, or with a time,2026-11-22T09:30:00Z. These work too: YAML's own dates, a time without a zone (2026-11-22 09:30, read as UTC), one with an offset (2026-11-22 09:30 +01:00), slashes for dashes (2026/11/22, Hexo's way), and a number of milliseconds since 1970. One that isn't (date: last Tuesday) fails the build with afront-mattererror at its line, listed with the page's schema errors. Collections are oldest first; undated pages come after the dated ones, in path order, so a fresh checkout or an edit (which changes file times) doesn't reorder them.page.updated: withlastModified: "git", when a page's file was last changed after it was added: its last commit, when an earlier commit added the file, or its modification time while it has changes that aren't committed (SOURCE_DATE_EPOCHpins that). It's unset for a file whose only commit is the one that added it, a file not committed yet, and a project that isn't a repository or has no commits, so the first commit afterssqch initdoesn't make every post "updated" that day. Show it only when it's after the date:{% if page.updated and page.updated > page.date %}(updated {{ readableDate(page.updated) }}){% endif %}in Jinja, as the blog starter'spostDatesfilter does. A renamed file's history starts at the rename, and a shallow clone has only the commits it fetched (check out the full history in CI,fetch-depth: 0).page.lastModifiedis still the last commit either way, for a sitemap or a "Last updated" line.lastModified: "file"gives nopage.updated: a file's time can't tell an edit from a copy.Equal dates: pages with the same date are in the order of their files' paths (the tie-break), compared folder by folder from the input folder down, and each name by its bytes, so uppercase comes before lowercase and a folder's pages before a file named like it:
posts/Z.md,posts/b.md,posts/cedar/a.md,posts/cedar-b.md,posts/cedar.md. The pages one template paginates into keep their own order. It's the same on every machine, whatever order the file system lists files in. To order them another way (by anorderin front matter, say), sort in a config collection:collections: { posts: (pages) => pages.byTag("posts").sort((a, b) => a.date - b.date || (a.data.order ?? 0) - (b.data.order ?? 0)) }. (localeComparesorts titles by language, but its answers can change between Node releases.) A config collection namedallreplacescollections.all(the tag collections keep their order), and for every template that reads it, so give it another name unless that's what you mean.SOURCE_DATE_EPOCH: set it (whole seconds since 1970, the reproducible-builds convention:SOURCE_DATE_EPOCH=1767225600 ssqch build) to pin the build's time, as Jekyll'stime:does.now()in Jinja and Nunjucks, Liquid's"now", Edge'snew Date(), the date of every page without one and apage.lastModifiedthat comes from a file's time become that time, so two builds of the same files write the same pages. A value that isn't a number is an error before the build starts. A site's own JavaScript (Date.now()in a filter) isn't changed.Drafts:
draft: truebuilds the page in development (ssqch serve, or--env development) and leaves it out of production builds, collections included.Excerpts and reading time:
page.excerptis the HTML before a<!-- more -->comment, or else the first paragraph, for layouts and collections (post.page.excerptin a list of posts).readingTime(content)is the minutes it takes to read some HTML at 200 words a minute (readingTime(content, 250)for another pace), at least 1.Slugs:
slugify("Pine Cone Crunch!")ispine-cone-crunch: lowercase letters and digits, with a dash for each run of anything else (apostrophes are dropped, and letters outside ASCII are kept). It's the same function in every template language ({{ title | slugify }}in Jinja, Nunjucks and Liquid), and a config filter namedslugifyreplaces it.slugify(title, { separator: "_" })(orslugify(title, "_"),{{ title | slugify: "_" }}in Liquid) puts another separator between the words, for URLs like/recipes/taco_bake/. Apostrophes are dropped (Drew's Browniesisdrews-brownies);apostrophes: "separate"splits words there instead (drew-s-brownies), for a site whose URLs were made that way.ascii: truetakes accents off and spells out a few letters and symbols first, as theslugifypackage (Eleventy'sslugfilter; itsslugifyis another package) does (Thomas Sjögrenisthomas-sjogren,Straße & 50%isstrasse-and-50-percent; other scripts stay as they are), andstripTags: truedrops HTML tags first (Use <code>title</code>isuse-title). Another option is an error. Before replacing a site's own slug filter withslugify, build with both and compare withssqch diff: one changed URL is a broken link. Data files can import it, andslugger(), fromssqch.Choosing engines: pages are Jinja (
.jinja) unless you list other languages intemplateFormats, and.mdfiles run through Jinja first, then Markdown (change that withmarkdownEngineandhtmlEngine). Layouts follow the same rules, so a.htmllayout is a Jinja template by default. A template'srenderfront matter overrides it:render: mdfor Markdown only (handy for a post full of{{ }}code samples),render: [edge, md]for a chain, orrender: falseto write the body as it is. A layout chain can mix languages (a Markdown post in a Liquid layout that sits in an Edge one). Around here that's called trail mix.Text files with front matter (Jekyll renders any file that starts with
---, like a.jsor.txtfile): give the extension an engine that hands the text back,engines: { js: (s) => s }, add it totemplateFormats, and in that folder's directory data (assets/js/js.json), or in each file's front matter, set"render": "liquid,js"(Liquid first, or the engine you use) and"permalink": "{{ page.filePathStem }}.js"(filePathStemstarts with its own/), so the file keeps its name instead of becomingapp/index.html.ssqch scoutdrafts all three for a Jekyll site. The config and the modules it imports are never pages, solib/filters.jsstays code. A.scssfile with front matter needs nothing:sassPlugin()blanks it.Everything else: layout chaining,
page.*,templateContentin collections, and an error when two pages would write the same file. Every template can readssqch.version,ssqch.env,ssqch.serving,ssqch.generatorandssqch.base(the site'sbase,/repo, or""without one). It's global data like any other, so code that gets a page's data has it too: acomputedfunction'sdata.ssqch.base, andthis.data.ssqchin a filter. A script for production only, such as analytics, goes in anifonssqch.env, sossqch serveand development builds leave it out:{% if ssqch.env == "production" %}<script defer src="https://stats.example/script.js"></script>{% endif %}(ssqch build --env developmentbuilds without it).
Templates are Jinja by default; Edge, Liquid, Nunjucks, Handlebars and Mustache and EJS are a templateFormats entry away, and one site can use several.
When a template fails, the error names the file and line (counted as the file is, front matter included) and is followed by the lines it's about, with carets under the part the message names when it quotes one:
error: 1 error(s):
- rendering posts/pine.md with `jinja`: posts/pine.md:8: unknown filter `rnd` (did you mean `round`?)
--> src/posts/pine.md:8
6 | Crunchy, foresty, and only slightly sticky.
7 |
8 | The count is {{ sightings.total | rnd(1) }} so far.
| ^^^
A Jinja filter, test or function that doesn't exist says which one you probably meant, and so does a layout, a Jinja or Nunjucks template (include, extends, import) or an Edge include that isn't there (layout `bse` not found: no sightings in src/_includes (did you mean `base`?)). One that leads back to itself names the loop instead of running out of patience: we've passed this tree before. Layout loop: base.edge -> wrap.edge -> base.edge.
A sidebar from front matter
pagesTree builds the sidebar from the pages themselves, so a new page shows up in it by saying where it goes. Each page names its parent in nav, and order sorts the entries under each parent:
# guide/index.md
title: Guide
nav: { key: Guide, order: 1 }
# guide/packing.md
title: Packing
nav: { parent: Guide, order: 2 }
# trails/cedar.md: no page has the key "Trails", so it's a heading
title: Cedar Trail
nav: { parent: Trails, order: 1 }
A Jinja macro prints the tree, calling itself for each entry's children. An entry without a url is a heading:
{% macro tree(entries) %}<ul>
{% for e in entries %}<li>{% if e.url %}<a href="{{ e.url }}"{% if e.url == page.url %} aria-current="page"{% endif %}>{{ e.title }}</a>{% else %}<span>{{ e.title }}</span>{% endif %}{% if e.children %}{{ tree(e.children) }}{% endif %}</li>
{% endfor %}</ul>{% endmacro %}
<nav class="sidebar">{{ tree(collections.all | pagesTree) }}</nav>
<nav class="section">{{ tree(collections.all | pagesTree({ root: "Guide" })) }}</nav>
The first is the whole site: Guide (with Getting there and Packing under it), then the Trails heading with the Cedar and Old Growth trails. The second, with root, is what's below Guide only, for a sidebar that shows one section. A page without nav isn't in either. For a sidebar you'd rather write out by hand, _data/nav.yml and navTree do the same from data (the docs-sidebar example).
A photo album from a folder
A page for each album, with every photo in the album's folder, sized for the screen. Three pieces: a data file that lists the albums and their photos, a template that paginates over them, and imagePlugin() for the sizes.
The photos live in a folder each, src/photos/2025-summer/ and the rest, and data/albums.json names them. Two albums can have the same name:
[
{ "name": "Camp Photos", "folder": "2025-summer" },
{ "name": "Camp Photos", "folder": "2026-spring" },
{ "name": "The Cedar Trail", "folder": "cedar-trail" }
]
src/_data/albums.js adds each album's photos, with files(), and a slug that's different for each album, with slugger():
import { files, readData, slugger } from "ssqch";
const slug = slugger();
export default readData( "data/albums.json" ).map( album => ( {
...album,
slug: slug( album.name ),
photos: files( `src/photos/${ album.folder }/*.{jpg,jpeg,png}` ).sort( ( a, b ) => a.date - b.date )
} ) );
src/album.jinja is a page for each album:
---
pagination: { data: albums, size: 1, alias: album }
permalink: "/photos/{{ album.slug }}/"
---
<h1>{{ album.name }}</h1>
{% for photo in album.photos %}
<figure>
<img src="{{ photo.url }}" alt="">
{% if photo.dateFrom == "name" %}<figcaption>{{ photo.date | dateformat("%B %-d, %Y") }}</figcaption>{% endif %}
</figure>
{% endfor %}
And the index links each one, with the same slug: {% for album in albums %}<a href="/photos/{{ album.slug }}/">{{ album.name }}</a> ({{ album.photos | length }} photos){% endfor %}. The config turns the photos into sizes:
import { imagePlugin } from "ssqch/image";
export default {
plugins: [ imagePlugin( { widths: [ 400, 800 ], formats: [ "webp", "jpeg" ] } ) ],
};
- The addresses: the albums are
/photos/camp-photos/,/photos/camp-photos-1/and/photos/the-cedar-trail/. Withslugifyin the permalink instead ofslugger()in the data, the two "Camp Photos" would both be/photos/camp-photos/, and the build stops withoutput conflicts:album.jinja makes 2 pages that write to ./dist/photos/camp-photos/index.html.slugger({ separator: "_" })makescamp_photosandcamp_photos_1. - The photos: each
<img>becomes a<picture>with a WebP and a JPEG at 400 and 800 pixels, and itswidthandheight. Don't write awidthon the<img>: that pins it to one size. The originals aren't copied to the output, only the sizes the pages use. - The dates:
20250704_01.jpgand2026-04-12-stump.jpghave a date in their names, whichfiles()reads (dateFrom: "name");bench.jpgdoesn't, so its date is when the file last changed, and the template leaves its caption out. The sort puts each album's photos oldest first. - A new album is a folder and a line in
albums.json. A new photo is a file in the folder:files()reads the folders again on every build, andssqch serverebuilds when a file insrc/changes.
A page per item when titles repeat
Pagination over a list with repeated titles (two sightings are both a "Footprint by the creek") can't take its permalink from the title: with permalink: "/sightings/{{ sighting.title | slugify }}/", the two are one address, and the build stops with output conflicts: sighting.jinja makes 2 pages that write to ./dist/sightings/footprint-by-the-creek/index.html. slugger() is slugify with a memory: it numbers a slug it has made before. Give each item its slug in a data file, so the page's permalink and every link to it agree:
// src/_data/sightings.js
import { readData, slugger } from "ssqch";
const slug = slugger();
export default readData( "data/sightings.json" ).map( sighting => ( { ...sighting, slug: slug( sighting.title ) } ) );
---
pagination: { data: sightings, size: 1, alias: sighting }
permalink: "/sightings/{{ sighting.slug }}/"
---
<h1>{{ sighting.title }}</h1>
<p>{{ sighting.trail }} Trail</p>
A list of them links the same slug: {% for sighting in sightings %}<a href="/sightings/{{ sighting.slug }}/">{{ sighting.title }}</a>{% endfor %}.
- The addresses:
/sightings/footprint-by-the-creek/, and/sightings/footprint-by-the-creek-1/for the second. - Another separator:
slugger({ separator: "_" })makesfootprint_by_the_creekandfootprint_by_the_creek_1. It'sslugify's ownseparator(slugify(title, { separator: "_" })isfootprint_by_the_creek), andsluggertakesslugify's other options too (ascii,apostrophes,stripTags). - The order is part of the address: the first item with a title gets the plain slug. Add a repeat at the end of the list and the others keep their URLs; add it at the top and they all move along by one. For a list that grows at the top, put something of the item's own in the slug:
slug(`${sighting.title} ${sighting.trail}`). - One per list: two lists that each need their own numbering get a
slugger()each. In a data file that exports a function, make it inside the function (export default () => { const slug = slugger(); return ...; }), so each call counts from the start. One made outside starts over with each build too, keeping what it gave while the file loaded, so the URLsssqch servegives are the onesssqch buildwrites.
A photo album from a folder does the same for albums with the same name.
Tags and tag pages
A post's tags (tags: [sightings, trails] in its front matter, or in a directory data file such as src/posts/posts.json, which gives every post the posts tag) put it in a collection for each tag: collections.sightings is every page tagged sightings, oldest first. The blog starter (ssqch init) builds a page for each tag and one that lists them all from three pieces, ready to copy.
The list of tags, a collection in ssqch.config.js: each tag on a post, with its posts newest first, sorted by name. posts is left out, since every post has it.
collections: {
tagList: (pages) => {
const tags = new Map();
for (const post of [...pages.byTag("posts")].reverse()) {
for (const name of post.data.tags) if (name !== "posts") tags.set(name, [...(tags.get(name) ?? []), post]);
}
return [...tags.keys()].sort().map((name) => ({ name, posts: tags.get(name) }));
},
},
A page for each tag, src/tag.jinja: pagination over that list with size: 1 writes one page per tag, alias: tag names the one a page is for, and the permalink and title come from it.
---
layout: layout.jinja
pagination:
data: collections.tagList
size: 1
alias: tag
permalink: /tags/{{ tag.name | slugify }}/
computed:
title: "Tagged {{ tag.name }}"
---
<ul>
{% for post in tag.posts %}
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
{% endfor %}
</ul>
Every tag, src/tags.jinja, at /tags/:
---
layout: layout.jinja
title: Tags
---
<ul>
{% for tag in collections.tagList %}
<li><a href="/tags/{{ tag.name | slugify }}/">{{ tag.name }}</a> ({{ tag.posts | length }})</li>
{% endfor %}
</ul>
A post links its own tags the same way. The starter's layout has ownTags(tags), a function in its config that leaves out posts: {% for name in ownTags(tags) %}<a href="/tags/{{ name | slugify }}/">{{ name }}</a>{% endfor %}. With slugify in every URL, a tag with spaces or capitals (Old Growth) gets a clean address (/tags/old-growth/). Use it in all three places (the permalink, tags.jinja and the layout): a link without it fails the production build's link check with /tags/Old Growth/ (not found; did you mean /tags/old-growth/?). Two tags that slugify alike (Old Growth and old-growth) would write the same page, which fails the build with output conflicts and tag.jinja makes 2 pages that write to .../tags/old-growth/index.html. The sitemap lists every tag page (exclude: ["/tags/**"] leaves them out).
Without a config collection, pagination over collections itself makes a page per tag too: pagination: { data: "collections", size: 1, alias: "tag", filter: ["all", "posts"] }, then collections[tag] for its pages, oldest first. collections has the config's own collections in it as well (the starter's newestPosts and tagList), so add those to filter. The tagList collection above is what gives newest first and the counts, in one place.
A page for each group, with numbered pages
A catalog's category pages are pagination in two levels: a page for each category, and in it 24 products to a page, with page numbers. pagination pages through one list, so a data file makes that list: one entry for each page of each category, with its products and its neighbours' addresses. The template, src/categories/category.jinja, pages through it one entry at a time:
// src/_data/categoryPages.js
import { slugify } from "ssqch";
import products from "./products.js";
const SIZE = 24;
const byCategory = Map.groupBy(products, (p) => p.category);
export default [...byCategory].flatMap(([category, items]) => {
const slug = slugify(category);
const count = Math.ceil(items.length / SIZE);
const hrefs = Array.from({ length: count }, (_, n) => (n === 0 ? `/categories/${slug}/` : `/categories/${slug}/${n + 1}/`));
return hrefs.map((href, n) => ({ category, href, number: n + 1, hrefs, items: items.slice(n * SIZE, (n + 1) * SIZE) }));
});
---
pagination: { data: categoryPages, size: 1, alias: listing }
permalink: "{{ listing.href }}"
---
<h1>{{ listing.category }}{% if listing.number > 1 %}, page {{ listing.number }}{% endif %}</h1>
<ul>{% for p in listing.items %}<li>{{ p.name }}</li>{% endfor %}</ul>
<nav aria-label="Pages">{% for href in listing.hrefs %}<a href="{{ href }}"{% if href == listing.href %} aria-current="page"{% endif %}>{{ loop.index }}</a> {% endfor %}</nav>
With 40 packs, that's /categories/packs/ with 24 and /categories/packs/2/ with 16, each with the numbers 1 and 2, and a brand's pages are the same file with p.brand. The link checker checks every one of them, as it does any page. A link to a category's first page elsewhere (a product's breadcrumb) is /categories/{{ product.category | slugify }}/.
Money and units
Prices and weights print the same on every machine when they're spelled out by a filter of the site's own, as ssqch's date filters are, rather than with Intl or toLocaleString, whose answers can change between Node releases:
// ssqch.config.js
export default {
filters: {
// $1,234.50, with the thousands marked by hand.
money: (n) => {
const [whole, cents] = Number(n).toFixed(2).split(".");
return `$${whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}.${cents}`;
},
// 1,250 g is 44.1 oz.
ounces: (grams) => `${(Number(grams) / 28.349523125).toFixed(1)} oz`,
},
};
{{ product.price | money }} and {{ product.grams }} g ({{ product.grams | ounces }}). Another currency is another symbol and separators in the same few lines; a site in several languages passes the language and picks them by it.
A default date that a page's own beats
A page with no date of its own takes its file's time, or its last commit's with dateFallback: "git". A file's time is when a checkout or an editor last wrote it, so it differs from one checkout to the next, and while serving, a save moves it: the pages that show its date render again, and every page that reads collections when the site's code sorts by dates (The field guide, "What a rebuild renders"). With dateFallback: "git" (the starters set it), a save doesn't move it. A group of pages that should take another date when they have none (a guide, the newest product's day) gets it from computed in the folder's directory data, which sees the page's own date first:
// src/guides/guides.data.js
import products from "../_data/products.js";
const newest = products.map((p) => p.added).sort().at(-1);
export default { computed: { date: (data) => data.date ?? newest } };
A guide with date: 2026-10-05 keeps it, and one without gets the newest product's. A layout's computed: { date: ... } that returns a value without looking at data.date replaces every page's own, so a page that sets one, and even one with a date that isn't one, shows the layout's instead (The North Fake study's first guide showed the wrong day).
A post's "updated" line
A post that changed after it went up can say so: "Posted January 5, 2026, updated February 10, 2026". The date comes from front matter when the post writes one (updated: 2026-03-01, as Hexo's posts and many Jekyll ones do), and otherwise from git: with lastModified: "git" (the starters set it), page.updated (above) is the last commit that changed the post's file, and it's unset until a commit after the one that added it, so a new site's first commit doesn't make every post "updated" that day.
A filter in the config works the same in every template language, and keeps the rule in one place:
// ssqch.config.js
const day = (d) => d.toISOString().slice(0, 10);
export default defineConfig({
lastModified: "git",
filters: {
// "2026-01-05", or "2026-01-05, updated 2026-02-10" once it changed on a later day.
postDates: (page, updated) => {
const changed = updated ?? page.updated;
return changed && day(changed) > day(page.date) ? `${day(page.date)}, updated ${day(changed)}` : day(page.date);
},
},
});
Call it as {{ postDates(page, updated) }} in Jinja, Nunjucks and Edge, and {{ page | postDates: updated }} in Liquid. The blog starter's postDates filter does the same with its readableDate. Without a filter, in the layout itself:
{# Jinja and Nunjucks #}
{% set changed = updated or page.updated %}
<p>Posted {{ page.date | dateformat("%B %-d, %Y") }}{% if changed %}, updated <time datetime="{{ changed | dateformat("iso") }}">{{ changed | dateformat("%B %-d, %Y") }}</time>{% endif %}</p>
{% assign changed = updated | default: page.updated %}
<p>Posted {{ page.date | date: "%B %-d, %Y" }}{% if changed %}, updated {{ changed | date: "%B %-d, %Y" }}{% endif %}</p>
@let(changed = updated || page.updated)
<p>Posted {{ page.date.toISOString().slice(0, 10) }}{{ changed ? `, updated ${changed.toISOString().slice(0, 10)}` : "" }}</p>
- Where git's date comes from: the last commit that changed the file, so fixing a typo counts as an update. To say "updated" only for changes that matter, write
updated:in front matter when you make one, and leavepage.updatedout of the line. - In CI, check out the whole history (
fetch-depth: 0in GitHub Actions), or every post looks as if its only commit added it, and none says "updated". A file renamed in a commit starts its history there. - A "Last updated" line on every page (a docs site's footer) is
page.lastModified, which is there from the first commit:page.updatedis for a post whose first version is its date. - For search engines and agents, the same date is JSON-LD's
dateModified("dateModified": "{{ changed | dateformat("iso") }}").sitemapPlugin()'s<lastmod>is the page's date, not this one.