Following the tracks: where a value comes from
In your terminal ssqch docs "Following the tracks: where a value comes from"
A page's data is a cascade. From the lowest level to the highest:
- Global data: files in a theme's
_data/, then the site's_data/(site.jsonissite), then the config'sdata. Alayoutthere (data: { layout: "base.jinja" }) is every page's that doesn't set one lower down: in directory data or front matter, wherelayout: falseturns it off. - Layouts: the front matter of the page's layouts, the outermost layout first.
- Directory data:
posts/posts.json(or.yaml,.toml,posts.data.js) applies to everything inposts/and below it. The outermost folder goes first. - The page's data file:
pine.jsonorpine.data.jsnext topine.md. - Front matter.
computed: worked out last, from everything above. A computed value that readscollectionssees them as they are without the pages that wait for them, the way a page paginated over a collection does. A computedlayoutcan depend on the page (layout: (data) => data.wide ? "wide.html" : "post.html"): each page then gets the layouts its value names, with their front matter below the page's data, and""orfalsefor none. It can't setpage(ssqch's own: a computedpageis an error, which names the file).
A higher level replaces what a lower one set. Objects merge key by key and lists are joined (a post's tags add to its folder's), unless deepMerge is off. page and ssqch are built in.
When a value isn't what you expected, ssqch trace follows its tracks back to the level that set it. Give it a page's URL or its template's path:
ssqch trace /guides/pine/
/guides/pine/
From src/guides/2024-03-02-pine.md (jinja, md)
Writes dist/guides/pine/index.html
Layouts _includes/guide.jinja > _includes/base.jinja
Date 2024-03-02T00:00:00Z (from the file's name)
Collections all, guides
Data (name, value, and the level of the cascade that set it)
site {name, author} src/_data/site.json
ssqch {version, generator, env, serving, …} built in
section "guides" layout _includes/guide.jinja (over layout _includes/base.jinja)
layout "guide.jinja" src/guides/guides.json
tags [1 item] src/guides/guides.json
level "hard" front matter (over src/guides/guides.json, src/guides/2024-03-02-pine.json)
permalink "/guides/{{ page.fileSlug }}/" src/guides/guides.json
computed {label} src/guides/guides.json
title "Pine" front matter
page {url, outputPath, inputPath, fileSlug, …} built in
label "Pine (hard)" computed
--field shows one value in full, with every level that set it:
ssqch trace src/guides/2024-03-02-pine.md --field level
level = "hard"
Set by (the last one wins):
src/guides/guides.json "easy"
src/guides/2024-03-02-pine.json "medium"
> front matter "hard"
- Inside a value: a dotted path reaches into objects (
--field site.author.name,--field hero.alt). - Dates from git: with
lastModifiedset, aModifiedrow says wherepage.lastModifiedcame from (git: the last commit to src/privacy.md), and when git had nothing, why it's the file's time instead (`lastModified: "git"`, but the project isn't in a git repository, orbut it has changes that aren't committed); a production build says the project's reason in a note (a development build, likessqch serve's, doesn't) and a file's own reason quietly, so this is where to look.Datesays the same withdateFallback: "git", and--field page.lastModifiedand the JSON (lastModified: { value, from }) do too. - Pages made by pagination: a template that makes many pages needs the URL of one of them.
ssqch trace src/tags.jinjalists them. - Scripts and agents:
--format jsonprints the report as JSON (schemaVersion: 1), withvalue,fromandsetByfor each field. - No page is built: it reads the site as a build does, up to the point of rendering.
beforeBuildhooks run, since data can depend on them (a command that writes a data file, a plugin that sets itself up there), but no page is rendered or written, andafterBuilddoesn't run. Standard output is only the report; anything a hook orconsole.logprints goes to standard error.