Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Trail

Building

Single-page view · as markdown

Building and Serving

Trail / Building

Build a static site for publication or preview it while editing. You need a Trail binary on your PATH and a source directory containing trail.toml. For an empty directory, follow Building Your First Site. trail(1) documents the complete command interface.

Build the site #

  1. Change to the directory containing trail.toml.

  2. Build with description checks:

    trail build --strict
    
  3. Check that the command exits successfully and reports the output directory. The page count counts HTML pages, including print pages. Markdown mirrors, search files, and static assets are additional files.

Output defaults to dist/. Use --out <directory> to choose another location. The output directory is excluded from source scanning.

Own the output directory #

A successful build removes files it did not produce. Put additional files such as CNAME in the source tree and configure passthrough. Do not keep manually managed files in dist/.

A failed build does not prune output. It can have written some files before failing, so the directory can contain a mixture of old and changed pages. Unchanged files retain their modification times.

Preview changes #

  1. Start the development server from the source directory:

    trail serve
    
  2. Open the address printed by the server. It defaults to http://127.0.0.1:8724.

  3. Edit and save an article. Check that Trail reports a rebuild and the browser reloads the page.

  4. Stop the server with Ctrl+C.

The server watches merged trees and declared plugin dependencies. It ignores output paths and hidden files, and periodically reconciles source contents to detect missed events. Build Cache explains reuse and invalidation.

A failed initial build or rebuild prints a warning and keeps the server running. Fix the reported source problem and save again. Output is not rolled back after a failure.

Diagnose a failure #

Trail reports errors on stderr with the invocation name and source context. Usage errors also print a help pointer. Use trail help build to check arguments, or trail build --no-cache to reproduce a build without cached results.

Missing link targets fail builds by default. During a site reorganization, --allow-dangling-links turns missing targets into warnings; ambiguous links still fail. Resolve warnings before publishing.

--strict requires descriptions and warns about authored site-absolute links. It does not enable link validation: links are validated on every build. Writing Links and References explains the linking syntax.

Publish other output forms #

The Output Surface describes Markdown mirrors, print bundles, and discovery files. Use --render-llms-full when you need additional llms-full.txt copies. Use --cbpath <path> to publish a cache-busting copy.

Build Cache

Trail / Building

Trail reuses unchanged build work in build and serve. The first build fills a cache. Later builds reuse plugin output, heading and anchor data, rendered Markdown, complete pages, print bundles, source mirrors, and search files when their inputs match.

Cache location #

The persistent cache lives in .trail-cache/ under the site root. It is separate from dist/, is not published, and is ignored by the file watcher. Add .trail-cache/ to your source repository's ignore file.

Cache entries belong to the Trail executable that created them. Installing a different executable starts a separate cache. You can remove .trail-cache/ to reclaim space; Trail recreates needed entries. Successful builds discard entries from their executable's cache that they did not use. Complete pages and print bundles trade disk space for less repeated work. Their entries also retain the smaller cached results needed after an edit.

A missing, damaged, or unwritable cache causes Trail to compute the result again. A cache failure does not prevent a build.

Rebuild without cached results #

Pass --no-cache to bypass cache reads and writes:

trail build --strict --no-cache
trail serve --no-cache

This flag applies to every rebuild in that serve session. It leaves existing cache files in place. Output files whose bytes are unchanged retain their modification times.

What invalidates cached work #

Trail checks file contents. It does not rely on modification times alone. Changes to link targets, anchors, inline references, image dimensions, or rendering options invalidate the Markdown results that depend on them. Link and section lookups track the answers they used, including missing targets. An unrelated target change can reuse existing results; a newly ambiguous or missing target still produces the appropriate diagnostic. Page chrome, navigation, and build options are checked before reusing a complete page. Print bundles retain their own anchor prefixes and link destinations.

Search files are reused only when the ordered set of indexed URLs and rendered HTML is unchanged. Adding, editing, renaming, or deleting an indexed page rebuilds the search index, while unchanged fragments and chunks reuse their compressed bytes. Unchanged pages also reuse their parsed search data. Global index packing still runs after an edit. Deleted pages and unused images are still removed from the output after a successful build.

Plugins must declare every file they read in depends_on, including imported helpers. A directory dependency tracks the names beneath it; also list the files whose contents affect the result. Trail checks those dependencies, the configured command, resolved executable, request inputs, and environment before reusing a successful response. Plugin failures are not cached. Plugin diagnostics are replayed on cache hits; moving a block that produced diagnostics reruns its plugin to refresh source locations. Independent plugins run in groups of up to four, limited by the available parallelism. Declared after dependencies run first. Results and diagnostics retain their dependency order, then name order, regardless of completion order. Plugins must not depend on undeclared execution ordering.

A plugin that depends on time, network state, or an undeclared input must be run with --no-cache when that input changes. See Plugin Blocks for the dependency contract.

Reuse within a build #

Article bodies render on up to four workers, limited by the available parallelism. Small sites use one worker. Results and diagnostics retain page order. Trail also shares parsed Markdown and highlighted code across article and print passes. These memory caches have limits: 256 MiB of accounted parsed events and 64 MiB of highlighted output per build thread. Search parsing and compression each use up to eight workers, limited by the available parallelism. The site and its cache-busting copy share prepared link, image, and inline-reference indexes.

Development server rebuilds #

serve keeps the authored site structure in memory. Changes to existing articles refresh those articles. Added, removed, or renamed files and configuration changes reload the structure. Plugin expansion, aliases, reading times, links, and other derived results are checked on each build. An uncertain watcher event also triggers a full reload.

The server compares source contents during rebuilds. It also checks for missed changes every 30 seconds, including declared plugin dependencies. These checks do not reload the browser when nothing changed. --no-cache disables reuse of the retained site structure.

Output comparisons use bounded buffers. Unchanged files keep their modification times; missing or modified output files are repaired during the next build, even when their size and modification time are unchanged.

The cache does not remove build features. Strict validation, diagnostics, Markdown mirrors, print bundles, search, and the cache-busting copy remain part of the build.

Configuring the Site

Trail / Building

One trail.toml at the site root configures the whole site. It is the only place these settings live — there is no per-environment config, no CLI equivalent for most of them, and unknown keys are build errors rather than typos you find out about later.

sitename = "Peios Learn"
title = "Documentation for everything Peios"
url = "https://learn.peios.org"
accent = "#3b82f6"
description = "Concepts, guides, and reference for the Peios operating system and every project around it — from the kernel to the toolchain that builds it."

featured = ["peios", "pekit", "provium", "universal-directory", "trail"]

footer = "Peios Learn — documentation for the Peios project."

trail.toml(5) is the authoritative key reference; this page is what each setting is for.

Complete the task #

  1. Open the existing site root's trail.toml, or create it with the required values shown below.

  2. Set the presentation and publishing values needed for the site. trail.toml(5) describes accepted keys and defaults.

  3. Run trail build --strict from that directory and resolve configuration errors.

  4. Preview the output and check the site name, navigation, footer, and public URLs.

The four required keys #

sitename, title, description, and footer must all be present.

sitename is the site's identity: the wordmark in the header, the suffix on every page's <title>, the search box's placeholder, and og:site_name. Its last word is accented in the wordmark — "Peios Learn" — so a two-word name reads best. A one-word name gets no accent.

title and description are the front page's headline and standfirst, and its meta description and social-preview text. The description is also the first line of llms.txt, so write it as a summary of the whole site rather than a slogan.

footer is the line at the foot of every page. Beneath it, "Built with Trail." appears unless built_by_trail = false turns it off.

The base URL #

url = "https://learn.peios.org"

Optional, and worth setting before you deploy. Without it:

  • no sitemap.xml is written, because sitemaps require absolute URLs, and robots.txt gets no Sitemap: line;
  • canonical URLs stay root-relative rather than absolute;
  • og:url is omitted, since a relative one is meaningless to the crawlers reading it;
  • /print bundles link outward relatively, which is right on the site and wrong on paper.

Trailing slashes are trimmed, so https://learn.peios.org/ and https://learn.peios.org behave identically.

Note

Trail builds for the root of a domain. Internal links are root-relative (/pekit/reference/cli), so serving the site from a subpath is not supported.

Featured products #

featured = ["peios", "pekit", "provium", "universal-directory", "trail"]

The list does two jobs: it orders products, and it decides which appear on the front page.

  • Products in the list sort first, in the list's order; everything else follows, by title.
  • Only listed products get a card on the front page. An unlisted product is still built, still searchable, still linkable, and still in the header's documentation menu.
  • Naming a product that does not exist is a build error.

Header navigation #

[[nav]]
label = "Specs"
url = "~specifications/pgss"

[[nav]]
label = "Source"
url = "https://github.com/peios/peios"

Each [[nav]] block adds a link beside the documentation menu. On narrow screens they move inside that menu.

Keep the [[nav]] blocks at the end of the file: in TOML every key after a table header belongs to that table, so an ordinary key written below them becomes a nav field and fails the build.

url can be an external URL, a root-relative path, or a ~ page reference. References are resolved strictly, at load time — even with --allow-dangling-links, a broken nav link fails the build. Site chrome appears on every page; it must never dangle.

Favicon #

favicon = "favicon.png"

A path relative to the site root. The file is copied to the output root under its own name and linked from every page. The file must exist, or the build fails.

Naming a file here is also what makes it legal to keep in the site root, which otherwise accepts trail.toml, *.product, and *.antho directories.

Edit links #

edit_url = "https://github.com/peios/learn/edit/main/{path}"

Adds an "Edit this page" link to the foot of every article. {path} is replaced with the article's source file path relative to the site root — the placeholder is required, and a template without it is a build error.

For an alias page the link points at the original's source file, since that is the file to edit.

Pages from a merged tree use that tree's own edit_url, with {path} relative to that tree's root, because the tree usually lives in a different repository. A merged tree without edit_url gets no edit links, unless it is fetched from a GitHub repository.

Injecting your own head HTML #

head_html = "head.html"

A path to a file whose contents are injected verbatim at the end of every page's <head>: analytics snippets, extra meta tags, a webfont, a verification token.

It is inserted unescaped and unchecked, at the end of the head, so it can override earlier tags. It is the escape hatch for everything trail does not have a setting for — and, like all escape hatches, the thing to reach for last.

Files trail does not build #

For downloadable files or source bundles, use Attachments. Attachment declarations provide checked references, automatic packaging, and size and checksum metadata. Use passthrough for files that need an unchanged public path.

passthrough = ["CNAME", ".well-known"]

Some files have to be in the published site without trail having any opinion about them: a CNAME for a custom domain, a .well-known/ directory, a search-engine verification file. passthrough names them, and each one is copied into the output exactly as it is — directories whole.

This matters most when the site root is a repository root. Trail accepts root collections and trail.toml there, so a CNAME sitting beside them would otherwise fail the build. Naming it here makes it legal and publishes it.

Two details worth knowing:

  • Entries are copied after everything trail generates, so naming robots.txt replaces the generated one — useful, and a foot-gun if you name assets.
  • Dot-entries like .github/ are already skipped by the root scan, so they only need naming here if you want them published. .well-known/ does; .github/ does not.

Tip

A repository whose root is a trail site cannot hold a README.md — it is an unexpected root file. Put it at .github/README.md, which GitHub renders on the repository page and trail skips.

Theming #

Four keys control color:

accent = "#3b82f6"
accent_dark = "#7aa8ff"     # optional; derived from accent if absent
custom_css = "custom.css"   # optional
product_theming = true      # default

accent is the site's color. accent_dark overrides its dark-mode variant, which is otherwise derived by mixing the accent toward white. custom_css names a stylesheet shipped at /assets/custom.css and loaded after the built-in one. product_theming = false stops each product tinting its own pages.

Both colors must be #rrggbb, and setting accent_dark without accent is an error. Theming covers what these actually reach.

What can live in the site root #

The site root accepts trail.toml, root collections, the build output directory, dot-entries (.git and friends), and whatever favicon, custom_css, head_html, passthrough and [[merge]] name. A setting naming assets/site.css makes the whole assets/ directory legal at the root — it is the first path component that is tolerated. Anything else is a build error.

That last clause is the reason those three settings take paths rather than inline content: naming a file is what makes it part of the site.

The Output Surface

Trail / Building

A build writes rather more than the pages you authored. This page is the full inventory of what lands in the output directory and what each part is for.

dist/
├── index.html                        the front page
├── 404.html                          the not-found page
├── robots.txt
├── sitemap.xml                       only when the site config has a `url`
├── llms.txt                          the site's map, for language models
├── site.json                         the site's structure, machine-readable
├── pekit.md                          a product, as markdown
├── pekit/
│   ├── index.html                    the product landing page
│   ├── print/index.html              all of pekit on one page
│   ├── print.md                      all of pekit as one markdown file
│   └── reference/
│       ├── cli/index.html            an article
│       ├── cli.md                    the same article, as markdown
│       ├── print/index.html          all of the Reference topic on one page
│       └── print.md
├── assets/                           style.css, search.js, fonts, licences
└── pagefind/                         the search index and its WASM core

HTML pages #

One page per article, product, anthology and book cover, plus the front page, the 404 page and one /print page per unit. Each is written as <path>/index.html, so /pekit/reference/cli needs a host that serves directory indexes — nearly all of them do.

Topics, subfolders, chapters, and shelves have no page. The count trail build prints is exactly this set.

Single-page views: /print #

Every unit — a product, an anthology, a topic, or a book — also publishes its whole contents as one page:

/pekit/print                  every article in pekit, in reading order
/pekit/reference/print        every article in the Reference topic
/peios/pgss/print             the whole book

Each article becomes a section with its title, its breadcrumb, and a heading id unique within the bundle. The page is styled for reading and for printing: browser chrome, the site header and footer, the pager and the tab buttons all drop out when it goes to paper, and tab panels expand so nothing is hidden.

Links are rewritten so the document works away from the site: a link to a page inside the same bundle becomes an in-document anchor, and one outside it becomes an absolute URL when the site config has a url, staying root-relative otherwise.

Every article page carries a "Single page" link in its breadcrumbs, pointing at its unit's bundle anchored at that article — so a reader can go from a page to the whole document without losing their place.

Two things do not carry over into a bundle: inline reference phrases and § citations are not linked there. RFC-2119 keywords still are.

A unit with no articles gets no bundle.

Markdown mirrors #

Every page is also available as markdown at its own URL with .md appended.

/pekit/reference/cli      →  /pekit/reference/cli.md
/pekit                    →  /pekit.md
/pekit/reference/print    →  /pekit/reference/print.md

A mirror is the article's source, not a re-derivation of the HTML — the same headings, the same fenced code blocks with their info strings, the same tables — with three rewrites:

  • ~ references become the target's own .md URL, so following links keeps you in the markdown surface;
  • Relative image destinations become the images' published URLs, since the mirror is served away from the article's folder;
  • Inside a book, h2/h3 headings gain their section numbers as text.

Plugin blocks are the one place a mirror departs from what was typed: it shows the plugin's expanded output, not the fence that asked for it.

Each one opens with the title, the breadcrumb trail, and the description:

# Installing

_Acme CLI / Guides_

> How to install Acme.

See [Hello](/docs/guides/hello.md) first.

Related content:

- [Hello](/docs/guides/hello.md)

Every HTML page also advertises its mirror in the head:

<link rel="alternate" type="text/markdown" href="/pekit/reference/cli.md">

llms.txt #

A map of the site at the root, following the llms.txt convention: the sitename and description, a note that every page has a .md twin, and then one section per product listing its units by their print.md bundles.

# Peios Learn

> Concepts, guides, and reference for the Peios operating system…

Every page on this site is also available as markdown at the same URL with
`.md` appended. Each section below links whole units as single markdown
files. The full machine-readable structure is at /site.json.

## pekit

- [pekit overview](/pekit.md): The recipe-driven build and packaging tool…
- [All pekit docs in one file](/pekit/print.md)
- [Getting started](/pekit/getting-started/print.md): 2 articles

The --render-llms-full flag additionally writes each unit's print.md as llms-full.txt beside it, for agents that probe for that filename rather than reading llms.txt. It is off by default: it duplicates a large part of the output and adds nothing new.

site.json #

The whole site model as JSON: the site's own metadata, root collections, and inside them the full tree of anthologies, topics, folders, books, chapters and articles.

The products array includes products and root anthologies. Its kind field is product or anthology. Both use the same item and URL structure. A collection's shelf field names the slug of the root shelf it sits on, or is null. Its icon field is the URL of the collection's published icon, or null when it shows its monogram. The shelves array lists the root shelves in order, each with its slug and title.

{
  "sitename": "Peios Learn",
  "url": "https://learn.peios.org",
  "llms": "/llms.txt",
  "shelves": [{ "slug": "tools", "title": "Tools" }],
  "products": [
    {
      "kind": "product",
      "slug": "pekit",
      "shelf": "tools",
      "path": "/pekit",
      "md": "/pekit.md",
      "print": "/pekit/print.md",
      "title": "pekit",
      "monogram": "pk",
      "icon": null,
      "color": "#22c55e",
      "description": "…",
      "items": [
        {
          "kind": "topic",
          "slug": "reference",
          "path": "/pekit/reference",
          "print": "/pekit/reference/print.md",
          "title": "Reference",
          "entry": "/pekit/reference/recipe-format",
          "children": [
            {
              "slug": "cli",
              "path": "/pekit/reference/cli",
              "md": "/pekit/reference/cli.md",
              "title": "Command-line reference",
              "type": "reference",
              "description": "…",
              "related": ["/pekit/running/invocation"]
            }
          ]
        }
      ]
    }
  ]
}

Every node carries the URLs of its own alternative representations, so a consumer can walk the structure and fetch exactly the parts it wants. Book entries add number and, for appendices, appendix: true; alias pages add original.

sitemap.xml and robots.txt #

robots.txt is always written, allowing everything, with a Sitemap: line when the site config has a url.

sitemap.xml is written only when it has one, because sitemaps require absolute URLs. It lists every HTML page — the front page, products, anthologies, book covers, articles, and /print bundles — each with a <lastmod> taken from that page's updated: date, or for a container, from the most recent one beneath it. Alias pages are left out: their canonical is the original.

The 404 page #

404.html is a real page in the site's theme, carrying <meta name="robots" content="noindex">. Trail writes it; your host has to be told to use it. trail serve already does, and returns a real 404 status with it.

Search #

/pagefind/ holds a Pagefind index built from the rendered pages: the index chunks, the WASM search core, and the pagefind.js module the theme's search script imports.

The front page is not indexed. Neither are alias pages — the original covers the same content — nor the parts of a page marked as chrome: breadcrumbs, the meta line, the Related Content list, the pager and the edit link. Each indexed page carries its breadcrumb trail as metadata, which is what search results show under the title.

Assets #

/assets/ holds the stylesheet, the search script, the two variable fonts with their licenses, and LICENSE-Syntaxes.txt — the licenses of the bundled syntax-highlighting definitions, which ask to travel with them. mermaid.min.js and its license join them only if some article on the site contains a diagram. A configured custom_css ships as /assets/custom.css; a configured favicon ships at the output root under its own name.

Images are published at the URL of the directory they were found in — but only the ones some article actually references. See Images.

The cache-busting copy #

--cbpath <PATH> adds one more entry to the output: dist/<PATH>/, holding everything above a second time, with every link inside it rewritten to stay inside it. It is how you get a URL that no cache can have seen. See The cache-busting copy.

Passthrough files #

Anything named by the root config's passthrough is copied in verbatim — a CNAME, a .well-known/ directory, a verification file — keeping its path relative to the site root. It is written after everything else, so a passthrough named for a generated file (robots.txt) replaces it.

Passthrough files are tracked like any other output, so they survive the prune between builds.

The Cache-busting Copy

Trail / Building

Static hosts serve your pages with cache headers you do not control. GitHub Pages sets its own; so does every CDN in front of it. For the minutes or hours those headers claim, a reader — or, far more often, an automated fetcher — can be served the previous build with nothing to tell them apart.

--cbpath answers that by publishing a second, complete copy of the site under a path you name:

trail build --cbpath 8f3a91c
built 1227 pages (8 collections) → ./dist
cache-busting copy → ./dist/8f3a91c/

Now /8f3a91c/ is the site's front page and /8f3a91c/pekit/reference/cli is that article. Name the copy after something that changes on every deploy — a commit hash — and every URL inside it has never been requested by anyone, so nothing anywhere can have it cached. What you get back is necessarily this build.

Why a copy and not a redirect #

The obvious cheap version — one busted URL that redirects, or a byte-for-byte copy of the tree — does not work, and fails in a way you cannot see.

Every URL trail emits is site-absolute: /pekit/reference/cli, /assets/style.css, /pagefind/pagefind.js. A plain copy at /8f3a91c/ would serve you a fresh HTML document for the one page you asked for, and that document would then load the cached stylesheet, the cached search script, and every link out of it would land back in the cached tree. One select and you are reading the old build again, with nothing on the page to say so.

So the copy is not copied. It is built, with the path baked into every URL it emits.

What carries the prefix #

ItemMeaning
Every link between pagesbreadcrumbs, sidebars, cards, the pager, ~ references in prose
§ section citations and inline referencesLinks stay inside the copy
Images that live in the treethe ones trail publishes for you
Assetsthe stylesheet, the search script, mermaid, your custom.css, the favicon
The search indexso a result inside the copy stays inside it
The whole markdown surface.md mirrors, print.md, llms.txt, site.json — the copy is mostly for machine readers, so these matter most
passthrough entriescopied into the copy as well as the site

And what does not:

ItemMeaning
<link rel="canonical">names the real page, so the copy never competes with it
URLs you wrote out in fullhttps://…, and a leading-slash path you typed yourself — trail emits those exactly as written rather than second-guessing them
edit_urlit points at your repository, not at the site
robots.txt and sitemap.xmlsee below

Search engines #

The copy is a complete duplicate of the site at a path that changes on every deploy — exactly the thing a search engine should never index. Trail makes sure it isn't:

  • Every page in the copy carries <meta name="robots" content="noindex, follow">;
  • Every page names the real page as its canonical;
  • The copy has no sitemap.xml, and the site's sitemap does not mention it.

There is deliberately no Disallow in robots.txt. Some automated fetchers honor robots.txt on a URL you handed them directly, and blocking the copy would defeat the point of having it.

The path #

One plain segment, made of letters, digits, -, _ and ., not starting with a dot. It must not be a path the site already uses — a product slug, assets, pagefind, site.json, a passthrough entry — or the copy would bury it. Trail checks before it builds anything:

Error: --cbpath 'assets' is already a path in the site; the copy would bury it — pick a name the site does not use

What it costs #

The output roughly doubles: twice the pages, twice the mirrors, a second search index. On a large site that is real — Peios Learn goes from 115 MB to 232 MB, and its deploy artifact from 27 MB to 54 MB. Build time roughly doubles too. Nothing about the site itself gets slower; the copy is only ever fetched by someone who asks for it by name.

In a deploy #

The point is to inject the commit, so the path is new on every push:

- name: Build site
  run: trail build --cbpath "${GITHUB_SHA::8}"

On a push, GITHUB_SHA is the commit that actions/checkout checked out, so the path and the content it names cannot disagree. The first eight characters are plenty to be unique per deploy and short enough to paste by hand.

Each deploy replaces the output wholesale, so only the current commit's copy exists at any moment — the previous one is pruned along with everything else the build did not write. Do not bookmark one.

Finding it as a reader #

The site itself learns where its copy is, and the search box gets a command for it. Type /cb (or /cachebust) and you land on the same page you were reading, in the copy. Type it again from inside the copy and you come back out. See the reading experience.

Theming

Trail / Building

Trail ships one theme, compiled into the binary. There is no template directory to override and no theme to install. What you do control is color — through configuration for the ordinary cases, and through CSS custom properties for everything else.

Complete the task #

  1. Open the existing site root's trail.toml and choose its accent settings.

  2. Use the settings described below; add custom CSS only for changes the built-in settings do not cover.

  3. Run trail build --strict from the site root.

  4. Preview the site in light, dark, and system modes, checking text contrast and image variants.

The three color settings #

accent = "#3b82f6"          # the site's colour
accent_dark = "#7aa8ff"     # optional; derived from accent if absent
product_theming = true      # default

accent is the site's color: links, focus rings, the wordmark's accented word, the hero glow, the front-page cards. Without it the theme's own default is used.

accent_dark is the dark-mode variant. Without it, trail derives one by mixing the accent 75% toward white — a light accent reads badly on a dark background, and most brand colors need lifting. Set it explicitly when the derived one is wrong. Setting it without accent is a build error.

Both must be #rrggbb.

Each product also has a color, and by default it displaces the site accent on every page belonging to that product: cards, the monogram tile, sidebar highlights, heading numbers, RFC-2119 keywords, focus rings. product_theming = false turns this off site-wide — every per-product tint collapses to the site accent, and products keep only their monogram and their card.

Three-state light and dark #

Every reader is in one of three states, and the header toggle cycles between them:

StateMeaning
SystemFollow the operating system's preference. The default.
LightPinned light, whatever the system says.
DarkPinned dark, whatever the system says.

The choice is stored per reader in their browser and applied before first paint, so a reader who has chosen dark never gets a flash of white.

In CSS this is three blocks: :root carries the light tokens; :root[data-theme="dark"] overrides them when the toggle has pinned dark; and @media (prefers-color-scheme: dark) :root:not([data-theme="light"]) overrides them for system-dark readers who have not pinned light.

Important

If you write custom CSS with colors in it, follow the same three-state pattern. Defining a color only inside a prefers-color-scheme block means the header toggle cannot override it, and a reader who pins light on a dark machine gets your dark color on trail's light page.

The tokens #

Everything resolves through CSS custom properties, so overriding a token restyles every place it is used.

TokenMeaning
--bgPage background.
--surfaceCards, menus, the sidebar — translucent over the background.
--textBody text.
--text-mutedSecondary text: crumbs, meta lines, captions.
--border, --border-strongHairlines and emphasized edges.
--accentThe site accent, as resolved for the current theme.
--pcThe product color in scope. Falls back to --accent.
--glow, --glow-mixThe accent glow behind heroes.
--headlineThe gradient headings are painted with.
--tile-mix, --tile-fg-mixHow strongly monogram tiles take their product color.
--card-shadowCard elevation.
--menu-bgThe products dropdown, which must be opaque.
--code-comment, --code-keyword, --code-string, --code-constant, --code-function, --code-typeThe syntax-highlighting palette.

--pc is the one to know. It is set inline on every element scoped to a product, which is how one stylesheet tints five products differently — and why product_theming = false can collapse them all with a single rule.

Syntax highlighting follows the theme #

Code is highlighted at build time into class names, not inline colors: hl-comment, hl-keyword, hl-string, and so on. Those classes resolve through the six --code-* tokens above, which are redefined in each theme state — which is why code goes light and dark with the rest of the page. Override those six tokens to change the code palette; see Code blocks.

Fonts #

Two variable fonts ship with the site and are served from /assets/fonts/: Inter for body text and Space Grotesk for headings. Both are self-hosted — no third-party font request — and their licenses ship beside them, as the SIL Open Font License requires.

To use different fonts, add @font-face rules and a font-family override in your custom stylesheet. The built-in fonts are still emitted; there is no setting to suppress them.

The custom stylesheet #

custom_css = "custom.css"

The named file ships at /assets/custom.css and is loaded after the built-in stylesheet, on every page.

Overriding tokens goes furthest, and survives changes to trail's own CSS:

:root {
  --accent: #0f766e;
  --card-shadow: none;
}
:root[data-theme="dark"] { --accent: #5eead4; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent: #5eead4; }
}

Beyond that it is ordinary CSS against trail's own class names — .card, .sidebar, .admonition, .code-block, and the rest. Those class names are not a stable interface: they are what the compiled templates happen to emit today, and a trail upgrade can change them. Token overrides are the durable half.

Injecting into the head #

For anything that is not a stylesheet — a webfont link, an analytics snippet, extra meta tags — head_html names a file injected verbatim at the end of every page's <head>.

What you cannot change #

  • The templates. They are compiled into the binary and are not user-replaceable. Page structure is trail's.
  • The layout, beyond what CSS can reach.
  • The set of page types. There is no way to add a new kind of page.

That is the trade trail makes: no plugin system and no theme directory, in exchange for a single binary with nothing to install and one appearance to maintain.

The Reading Experience

Trail / Building

None of this needs configuring. It is what every trail site does, and it is here so you know what your readers have — and so you can write pages that make use of it.

Search #

⌘K — or Ctrl K, and the pills in the header say which, based on the reader's platform — opens a search modal from any page. So does selecting the search box in the header or the one on the front page.

Search is powered by a Pagefind index built at build time. The engine and its index chunks load lazily, on the first open, so a reader who never searches pays nothing for it.

  • Results show the page title, its breadcrumb trail, and an excerpt with the matches highlighted.
  • Up to eight results are shown; the status line says how many more there were.
  • ↑ and ↓ move; Enter opens; Esc or a select on the backdrop closes.
  • The query is carried through to the page, which highlights every occurrence of each term in the article body and scrolls the first into view. Matches inside code blocks and breadcrumbs are skipped.

What is indexed is the article body. Chrome — breadcrumbs, the meta line, Related Content, the pager, the edit link — is excluded, and so is the front page and every alias page.

Commands #

A query beginning with / is a command rather than a search. Typing / on its own lists the ones this page has; typing more narrows the list, and Enter runs the highlighted one.

CommandMeaning
/themeCycles system → light → dark, exactly as the header button does.
/theme <name>Goes straight to system, light, or dark.
/cachebust, /cbOpens the page you are on in the cache-busting copy — a URL nothing has cached. From inside the copy it takes you back out to the real page. Offered only when the build published a copy.

Nothing needs enabling. The commands a page offers are the ones that can do something there, which is why /cb appears on a site built with --cbpath and nowhere else.

Light, dark, and system #

The header's theme button cycles system → light → dark, and its icon shows which state is active. The choice is remembered in the reader's browser and applied before first paint, so there is no flash of the wrong theme.

"System" is the default and follows the operating system's preference live. See Theming.

Navigation #

The sidebar on an article page shows the article's own topic — its title above its contents in reading order, subfolders as collapsible groups (expanded automatically around the current page), and the current article marked. In a book it is the whole book as a tree with section numbers, chapters collapsible, and the trail to the current page opened. Chapters a reader opens by hand stay open as they move through the book, for that tab.

"On this page" lists the article's h2 and h3 headings in a right-hand column, and highlights the one in view as the reader scrolls. When the window is too narrow for a third column it moves into the sidebar. An article with no headings gets no list.

Every heading has a permalink — a # that appears on hover and links to that heading's stable id.

Previous and next links at the foot of an article step through the whole topic, or the whole book, in reading order.

Breadcrumbs run from the product down through anthologies, the topic and any subfolder.

A back-to-top button appears once the page has been scrolled past about 600 pixels.

Text size #

Three buttons at the top of the right-hand column set the prose to small, medium or large. The choice is remembered per reader.

It scales the article text only — the sidebar, header, and chrome stay put. Making the whole page bigger costs a reader half their screen; making the prose bigger is what they actually wanted. On narrow screens the controls ride into the drawer with the rest of the sidebar.

Code and content #

  • Every code block has a copy button, top-right, appearing on hover and always visible on touch devices. It says "Copied" briefly, and falls back to telling the reader to press ⌘C if the browser refuses clipboard access.
  • Syntax highlighting follows the theme, because it is class-based rather than baked-in colors.
  • Tables scroll inside their own container, so a wide table never makes the whole page scroll sideways.
  • Images carry their real dimensions, so text does not jump around as they load.
  • Tab groups keep one panel open at a time, independently per group.
  • Mermaid diagrams are drawn in the reader's theme, and the library is only shipped to pages that contain one.

Line breaks #

Some things read wrongly split across two lines, so Trail keeps them on one:

  • A spaced em dash stays with the word before it. In "the kernel — not the service — decides", a line never starts with —. The space before the dash becomes a non-breaking space, including where the source breaks a line before the dash.
  • A numeric range stays whole. "0–65535" never splits after its en dash.
  • A key combination stays whole. Ctrl+C never splits at its "+".

This happens only in the rendered page. Sources keep plain spaces, because a non-breaking space looks like an ordinary one but searches and compares differently. Code spans and code blocks are left exactly as written. A range or a key combination is wrapped in <span class="keep-together">, which a custom stylesheet can restyle. An invisible joining character would have ridden along into anything a reader copies.

Page furniture #

A meta line under the title gives the estimated reading time and, when the article has an updated: date, when it last changed. Containers total theirs up, so a book cover says how long the whole book takes.

A "Single page" link in the breadcrumbs opens the whole topic or book as one page, anchored at the article the reader was on. It is the right link for someone who wants to read the lot, print it, or search the whole document at once. See The output surface.

"Edit this page" appears at the foot of every article when the site config sets edit_url, pointing at the article's source file.

A "Related Content" list appears above the pager when the article's frontmatter has a related: list.

On small screens #

The sidebar becomes a drawer, opened by the menu button in the header and closed by the overlay, the button again, or following any link inside it. "On this page" and the text-size controls ride in with it, so nothing is lost on a phone.

On paper #

Every page prints. The header, footer, search modal, pager, "Single page" link, and back-to-top button all drop out; tab groups expand so every panel is visible, each labeled with its tab's name.

For printing a whole topic or book, use its /print view rather than printing pages one at a time.

Without JavaScript #

The pages are static HTML and read fine with scripts disabled. What is lost is the interactive layer: search, the theme toggle, text size, copy buttons, tab switching, the drawer, scroll-spying, and diagram rendering. Content, navigation links, the sidebar tree, and every ~link work regardless.

If search cannot load its index or a result, the dialog reports the failure. Enter a query again to retry. Results from an older query do not replace the active query or command list.

If the browser refuses to copy a citation, its link title reports the failure and contains the citation text. The link does not show copied feedback unless the clipboard write succeeds.

Peios Learn — documentation for Peios software.

Built with Trail.