Trail
The static site builder behind Peios Learn.
Single-page view · as markdown
What Is Trail
Trail / Getting Started
Trail is a static site generator for documentation. You give it a directory of markdown files arranged into named folders; it gives you a complete website — every page rendered, cross-linked, indexed for search, mirrored as markdown for machines, and bundled into printable single-page views.
This site is built with it. Everything you are reading, including this page,
comes out of one trail build.
The one idea: the tree is the site #
Trail has no table-of-contents file, no sidebar.json, no list of pages to
keep in sync with the pages themselves. The directory tree is the
navigation. A folder named 2--writing.topic is a topic called "Writing"
that sorts second; the .md files inside it are its articles, in the order
their own numeric prefixes give them.
learn/
├── trail.toml # the site
└── trail.product/ # a product
├── trail.toml
├── 1--getting-started.topic/ # a topic, sorted first
│ ├── 100--what-is-trail.md # an article, sorted first
│ └── 200--quick-start.md
└── 2--structuring-a-site.topic/
└── 100--products.md
Add a file, and the page exists, appears in the sidebar, joins the search index, and gets a markdown mirror. Rename a folder, and the section moves. Nothing else has to be told.
The trade is that names carry meaning. 100--quick-start.md is not a
decorative filename: 100 is the sort key and quick-start is the URL
segment. Directory and file names is the
exhaustive grammar;
Anatomy of a site is the guided
tour.
Strict by default #
The second principle is that mistakes are build failures, not silent surprises. A documentation site that quietly drops a page is worse than one that refuses to build.
- A key that
trail.tomldoes not define is an error, not an ignored line. - A file trail does not recognize — a stray
notes.txtin a topic, aREADME.mdwithout an order prefix — is an error, not a file left out of the site. - A
~linkwhose target are absents fails the build. Every broken link in the site is reported at once, so one run tells you the whole story. - An ambiguous
~link— one matching two pages — always fails, even under--allow-dangling-links. Trail will not guess which page you meant. - A frontmatter
updated:that is not an ISO date, a color that is not#rrggbb, a.linkalias pointing at another alias: all errors.
The escape hatches are deliberate and few. --allow-dangling-links downgrades
missing targets to warnings while you are mid-refactor; that is the whole
list.
One binary, no runtime #
Trail is a single Rust binary with everything compiled in: the templates, the
stylesheet, the fonts and their licenses, the search engine, the syntax
highlighter, the diagram renderer. There is no theme directory to install
beside it, no Node toolchain, no npm install step, and nothing to fetch at
build time.
The output is equally plain. dist/ is a directory of static files — HTML,
CSS, WOFF2, JSON, a WASM search core — that any static host will serve as-is.
There is no server component and no build step at request time.
What one build does #
trail.toml + the tree
→ load parse every trail.toml and every frontmatter block, validate names
→ resolve .link aliases, ~link targets, inline-reference phrases, images
→ render one HTML page per article, product, anthology and book cover
→ export .md mirrors, /print bundles, llms.txt, site.json, sitemap, robots
→ index the Pagefind search bundle, built from the rendered pages
→ prune delete anything in dist/ this build did not write
Loading is where nearly all the errors live: by the time rendering starts, the
site model is known to be well-formed. Pruning is why dist/ belongs entirely
to trail — a page you deleted from the source disappears from the output on
the next successful build, along with superseded search index fragments and
stale images.
Builds are fast enough not to think about. This site — over twelve hundred pages — builds from scratch in a little over three seconds.
What a site is made of #
Four kinds of thing, from the outside in:
| Item | What it is |
|---|---|
| Site | One trail.toml at the root, the front page, and the products. |
| Product | A documented thing (trail.product/) with its own color, monogram and landing page. |
| Grouping | How a product's pages are organized: anthologies, topics, books, and shelves. |
| Article | One .md file: YAML frontmatter, then markdown. |
The distinction that matters most is topic versus book. A topic is a set
of articles you can read in any order — a how-to section, a concept section. A
book is a formal, ordered document — a specification, a reference manual —
with a cover page, dotted section numbers (2.1.3), chapters that nest
arbitrarily deep, and lettered appendices. They render differently because
they are read differently.
What trail gives readers #
Beyond the pages themselves, every build produces:
- Search — a ⌘K modal over a Pagefind index, loaded lazily so pages carry no search cost until someone searches. Results carry the query through to the page, which highlights every match.
- Three-state theming — light, dark, or follow the system, remembered per reader. Syntax highlighting, diagrams, and images all follow it.
- Print and machine views — every topic, book, anthology and product is
also one long page at
/print, one markdown file at/print.md, and every individual page is mirrored at its own URL with.mdappended. - The reading furniture — a scroll-spying "On this page" list, copy buttons on code blocks, heading permalinks, adjustable text size, previous/next links, a mobile drawer, and a back-to-top button.
The reading experience covers all of
it; The output surface covers exactly
what lands in dist/.
What trail is not #
- Not a general-purpose SSG. There is no plugin system, no shortcode API, no way to add a page type. The templates are compiled in and are not user-replaceable; theming happens through CSS custom properties and an optional stylesheet.
- Not versioned. One build produces one version of the site. Hosting several versions means several builds at several paths.
- Not incremental. Every build renders every page. It is fast enough that this has never mattered.
- Not a subpath host. Sites are served from the root of a domain; internal links are root-relative.
Where to start #
If you want a working site in five minutes, go to the Quick start.
If you want to understand the layout before writing anything, read Anatomy of a site, then the Structuring a site section in order.
If you are writing pages in a site that already exists, Writing is the section you want — frontmatter, links, images, code blocks, and the rest.
Building Your First Site
Trail / Getting Started
This page takes you from an empty directory to a served, searchable
documentation site in about five minutes. You will write four files, run
trail build, look at what it produced, then switch to trail serve and add
a second page while it is running.
Complete the task #
-
Create the site directory and root configuration shown below.
-
Add the product, topic, and article files in the following sections.
-
Run
trail build --strictfrom the site root and check that it succeeds. -
Run
trail serve, open its printed address, and check that the article appears.
Prerequisites #
- A
trailbinary. Follow Building Trail to build and install it with pekit.tools/installinstalls it under$HOME/.local/bin. Put it on yourPATH, or call it by path — the examples below assumetrailis on yourPATH. - Nothing else. The templates, stylesheet, fonts, syntax highlighter, diagram renderer, and search engine are all compiled into the binary.
Create the site #
A trail site is a directory with a trail.toml in it. Make one:
&&
# acme-docs/trail.toml
= "Acme Docs"
= "Documentation for Acme"
= "Guides and reference for the Acme toolchain."
= "Acme — docs."
Those four keys are the only required ones. sitename is the wordmark in the
header (its last word is accented); title and description are the front
page's headline and standfirst, and feed the site's <meta> tags. Everything
else — the accent color, the base URL, header links, a favicon — is optional
and covered in Configuring the site.
Add a product #
Every page belongs to a product — a documented thing with its own landing
page, color and monogram. Products are directories named <slug>.product:
# acme-docs/docs.product/trail.toml
= "Acme CLI"
= "ac"
= "#3b82f6"
= "The command-line interface to Acme."
All four keys are required. The directory name gives the URL (/docs) and the
slug you link by; title is what readers see. The monogram is the two-or-so
characters shown on the product's tile on the front page and in the products
menu. A monogram longer than two characters is drawn smaller so that it still
fits, and up to four stay legible. An optional icon can show an SVG in the
tile's place instead. color tints the product's cards, sidebar, and
headings.
Add a topic and an article #
A topic is a set of articles read in any order. Topics are directories
named <order>--<slug>.topic:
Three things are going on in that filename and that frontmatter block:
1--guides.topic— the1sorts this topic among its siblings and never appears in a URL;guidesis the URL segment;.topicis the kind. With notrail.tomlof its own the topic's title is derived from the slug ("Guides").100--hello.md— same grammar for articles. Numbering in hundreds is a convention, not a rule: it leaves room to insert150--later without renumbering.title:andtype:are the two required frontmatter keys.description:is optional but worth writing — it becomes the page's meta description and its social-preview text.
Build it #
built 6 pages (1 collection) → ./dist
Six pages from one article, because trail writes more than the pages you authored:
dist/index.html the front page
dist/404.html the not-found page
dist/docs/index.html the product landing page
dist/docs/guides/hello/index.html your article
dist/docs/print/index.html all of Acme CLI on one page
dist/docs/guides/print/index.html all of Guides on one page
dist/docs.md the product, as markdown
dist/docs/guides/hello.md your article, as markdown
dist/docs/print.md all of Acme CLI, as one markdown file
dist/docs/guides/print.md all of Guides, as one markdown file
dist/llms.txt the site's map for language models
dist/site.json the site's structure, machine-readable
dist/robots.txt
Plus dist/assets/ (the stylesheet and fonts) and dist/pagefind/ (the
search index and its WASM core). Note that there is no page at /docs/guides — a topic has no page of its own. It shows up as a card on the product page,
and links to it land on its first article.
dist/ belongs to trail: at the end of every successful build it deletes
anything in there that the build did not write.
Serve it #
serving ./dist at http://127.0.0.1:8724 (watching . for changes)
trail serve builds the site, serves it, and watches the source tree. Save a
file and the browser reloads itself; break something and the error prints in
the terminal while the last good output keeps being served.
Open the site and try it: press ⌘K (or Ctrl K) to search, and use the theme button in the header to switch between light, dark and system.
Add a second page #
Leave the server running and add another article beside the first:
-
Two new things:
~docs/guides/hellois a page reference, not a URL. The first segment names a product; the rest matches the end of a page's path. Move or rename the target and the link still resolves as long as its slug is unchanged; delete it and the build fails rather than shipping a dead link. See Links and references.related:takes the same references (without the~) and renders a "Related content" list at the foot of the page.
Save, and the page appears in the sidebar next to Hello.
Where to go next #
- Anatomy of a site — the whole tree, level by level, with a real example.
- Products — the structuring section in order: products, anthologies, topics, books.
- Articles and frontmatter — every frontmatter key and what it does.
- Configuring the site — the base URL,
accent color, navigation links, edit links, and the rest of
trail.toml.
Anatomy of a Site
Trail / Getting Started
A trail site is a directory tree in which every name means something. This page walks that tree from the root down, and explains the naming grammar all of it shares. Directory and file names is the same material as an exhaustive table; Structuring a site covers each kind of container in depth.
The whole shape #
learn/ the site root
├── trail.toml the site config — required
├── dist/ the build output — trail's to manage
│
├── peios.product/ a product → /peios
│ ├── trail.toml required: title, monogram, color, description
│ ├── 1--security-fundamentals.antho/ an anthology → /peios/security-fundamentals
│ │ ├── trail.toml required: title, description
│ │ ├── 1--identity.topic/ a topic → /peios/security-fundamentals/identity
│ │ │ ├── trail.toml optional: title, inline_ref
│ │ │ ├── 100--sids.md an article → …/identity/sids
│ │ │ ├── 200--principals.md
│ │ │ ├── 300--tokens/ a subfolder → …/identity/tokens/…
│ │ │ │ ├── trail.toml optional
│ │ │ │ └── 100--issuing.md → …/identity/tokens/issuing
│ │ │ └── diagram.svg an image, published beside its article
│ │ └── 2--pgss.book/ a book → /peios/security-fundamentals/pgss
│ │ ├── trail.toml required: title, description; optional: short
│ │ ├── 1--scope.md §1 → …/pgss/scope
│ │ ├── 2--model/ a chapter, §2
│ │ │ ├── trail.toml optional
│ │ │ └── 1--objects.md §2.1
│ │ └── a1--glossary.md Appendix A
│ └── 2--tooling.shelf/ a shelf — a heading, not a URL segment
│ └── 1--pekit.topic/ → /peios/pekit (the shelf adds nothing)
│
├── pekit.product/ another product → /pekit
│
└── 1--tools.shelf/ a root shelf — a heading over products
└── provium.product/ → /provium (the shelf adds nothing)
A root anthology can replace a product when separate product branding is
not needed. It uses <slug>.antho and requires a title and description.
A root shelf groups products and root anthologies under a heading in the
Documentation menu and on the front page.
Everything below the root is optional. A site with one product, one topic, and
one article is a complete site; this site's trail.product is exactly that
shape, four levels shallower than peios.product.
The naming grammar #
These name shapes appear throughout the tree.
| Shape | Example | Where |
|---|---|---|
<slug>.product | pekit.product | Only at the site root or on a root shelf. |
<slug>.antho | peios.antho | An anthology at the site root or on a root shelf. |
<order>--<slug>.<kind> | 2--writing.topic | Anthologies, topics, books, shelves (root shelves too). |
<order>--<slug> | 300--tokens, 2--model | Topic subfolders and book chapters — no suffix. |
<order>--<slug>.md | 100--sids.md | Articles. |
<order>--<slug>.link | 3--faq.link | Aliases; see Link aliases. |
The parts:
<order>is a non-negative integer used only for sorting among siblings. It never appears in a URL or a title. Gaps are fine and normal — numbering articles100,200,300leaves room to insert. Two siblings sharing an order is an error, because the resulting page order would depend on nothing you can see.<slug>is lowercase kebab-case: ASCII lowercase letters, digits and hyphens, not starting or ending with a hyphen. It becomes the URL segment, and it is what you write in a~link.<kind>isantho,topic,book, orshelf.
Inside books, an order can also be written a<N>-- (a1--glossary.md). Those
are appendices: lettered A, B, C instead of numbered, and sorted
after every numbered sibling at their level. See
Books.
URLs #
A page's URL starts with its root collection slug, followed by each container between that collection and the page — with two exceptions.
peios.product/1--security-fundamentals.antho/1--identity.topic/100--sids.md
→ /peios/security-fundamentals/identity/sids
The exceptions:
- A shelf contributes no segment. It is a heading on its parent's page,
nothing more. A topic inside
2--tooling.shelf/lives at/peios/<topic>, exactly as if the shelf were not there. - Order prefixes contribute nothing.
1--identity.topicgives the segmentidentity.
Which containers have a page of their own is worth knowing, because it decides what you can link to:
| Item | Has a page | Links to it land on |
|---|---|---|
| Site | / | — |
| Product | /pekit | its own landing page |
| Anthology | /peios/security-fundamentals | its own landing page |
| Book | /peios/…/pgss (the cover) | the cover |
| Article | its own URL | itself |
| Topic | no page | (topics are not link targets) |
| Topic subfolder | no page | (not a link target, except from a .link) |
| Book chapter | no page | (not a link target) |
| Shelf | no page | (not a link target) |
Topics, subfolders, and chapters are real structure — they appear in sidebars,
cards and contents lists, and links from those surfaces open their first
article — but they have no page you can address, so a ~link cannot point at
one. Point at the article you actually mean.
Titles #
Titles come from three places, in order of precedence:
- An article's
title:frontmatter, which is required. - A container's
trail.toml, where thetitlekey is required for products, anthologies and books, and optional for topics, subfolders, chapters and shelves. - The slug becomes title case after hyphens become spaces:
the-two-gatesbecomes "The Two Gates", anddeveloping-for-peiosbecomes "Developing for Peios".
The derived form is good enough surprisingly often; write a trail.toml when
it is not — acronyms and casing it cannot guess ("Peiso", "The Console"), or
when the container needs inline_ref phrases.
What can sit where #
Trail rejects anything it does not recognize, so it is worth knowing what each level tolerates.
| Directory | Can contain |
|---|---|
| The site root | trail.toml, *.product/, *.antho/, .shelf/, the output directory, files named by the config |
| A product | trail.toml, .antho/, .topic/, .book/, .shelf/ |
| An anthology | trail.toml, .antho/, .topic/, .book/, .shelf/ |
| A shelf | trail.toml, the same as its parent minus shelves — a shelf never holds a shelf |
| A root shelf | trail.toml, *.product/, *.antho/ |
| A topic | trail.toml, .md articles, <order>--<slug>/ subfolders, .link files, images |
| A topic subfolder | trail.toml, .md articles, .link files, images |
| A book | trail.toml, .md articles, <order>--<slug>/ chapters, .link files, images |
| A book chapter | trail.toml, .md articles, <order>--<slug>/ chapters, .link files, images |
Only the article-holding levels take files: .md articles, .link aliases
and images can sit in a topic, a subfolder, a book or a chapter, and nowhere
else. A product, anthology or shelf directory holds trail.toml and
subdirectories, full stop.
Images sit beside the articles that use them and are published at the URL of the directory they were found in; see Images.
Two slugs are reserved: print (every container publishes a /print page)
can not be an article slug, and assets and pagefind can not be product
slugs.
Ordering #
Siblings sort by their <order> prefix, ascending. Within a book, appendix
entries (a<N>--) sort after every numbered entry at the same level, and they
are lettered rather than numbered.
Root collections have no order prefix. They sort by the root
config's featured list first, in that list's order, then everything else by
title. Root shelves sort by their prefix, after the collections outside any
shelf.
Where to go next #
- Products — the product level in depth, and when to add another one.
- Anthologies and shelves — grouping a large product.
- Topics and folders — the everyday container.
- Books — numbered, ordered documents with chapters and appendices.
Building Trail
Trail / Getting Started
Use these commands from the Trail source directory. pekit builds and tests Trail. Cargo manifests and the Cargo lockfile still define the Rust dependencies.
Prepare the host #
The supported build host is x86_64 Linux. Install pekit, with bubblewrap
0.11 or later, and Git. The first build needs network access to download
the pinned tools and dependencies. pekit downloads Rust 1.98.1, the C
toolchain, Node.js 22, Python, and the crates Cargo.lock records, and
checks each against its pinned hash. pekit.lock pins the libraries that
provide them.
Build and inspect the binary #
-
Build the executable:
pekit prints where the executable is, under
pekit-out/. -
Check the version and help:
The executable contains its templates, fonts, scripts, and search assets. Copying the binary does not require copying a theme directory. pekit builds each crate as its own step, in a sandbox that holds only its declared inputs. A rebuild reuses each step whose inputs did not change. Embedded theme and vendored Pagefind files are inputs, so changing them rebuilds the steps that read them.
The executable links glibc dynamically. The glibc test fails if it needs a
glibc newer than 2.39, the version on GitHub's Ubuntu 24.04 runners.
Run checks #
The style and manual checks also require Rust 1.98.1 with rustfmt from
rustup, Python 3.11 or later, ShellCheck, and groff. The formatter uses the
host Rust toolchain that rust-toolchain.toml selects. Prettier and Node.js
are the versions pekit pins.
-
Install the matching Rust formatting tools if they are absent:
-
Run the complete check set:
-
Confirm that all checks pass. The tests are Rust unit and subprocess tests, Clippy with warnings denied, the theme's browser scripts, a strict documentation build, and the glibc check. After them,
tools/checkchecks formatting, source hygiene, and manual rendering.
For a narrower check, name the tests:
The Rust tests run with the pinned Node.js, Python, busybox, and a Git built
from pinned source. A test whose inputs did not change is not run again.
GitHub runs tools/check --strict on every branch and pull request.
Format maintained sources #
This command edits the checkout. It formats first-party Rust, JavaScript,
CSS, embedded template scripts, and workflow files. It preserves imported
vendor layout except for Trail's maintained Pagefind patch files. Run
tools/check afterward to verify the result.
Install the executable and manuals #
Run this command to install under $HOME/.local:
The executable goes to bin/trail, and manuals go to share/man/man1 and
share/man/man5 beneath that prefix. Add the prefix's bin directory to
your PATH if needed. Check the installed executable with
$HOME/.local/bin/trail --version.
To select a different prefix, pass an absolute path:
Manage caches and dependency updates #
Removing pekit-out/ removes the build outputs in the checkout. pekit keeps
its store of steps outside the checkout, under its cache directory. Neither
holds the documentation cache described in
Build Cache or installed files.
Keep Cargo.toml and Cargo.lock together when updating Rust dependencies,
and update the lockfile with Cargo. pekit reads the lockfile and never
changes it. After a change to package-lock.json, run
pekit run pin_packages to write npm.pins again, and review both together.
Run pekit lock to move the pinned libraries to their latest commits.
Products
Trail / Structuring a Site
A product is the outermost division of a trail site: one documented thing, with its own landing page, its own color, and its own URL prefix. A site root accepts products and root anthologies. Every page belongs to one of those root collections.
On this site, pekit, provium and trail are products. So is peios
itself — products are not necessarily software packages, they are the largest
chunk of documentation a reader would think of as one subject.
The directory #
A product is a directory named <slug>.product at the site root, or on a
root shelf.
It has no order prefix.
learn/
├── trail.toml
├── pekit.product/ → /pekit
└── trail.product/ → /trail
A root shelf only adds a heading in the Documentation menu and on the front page. Its products keep the URLs they would have at the root.
The slug becomes the URL prefix (/pekit) and the first segment of every
~link into that product. It must be
lowercase kebab-case, and it can not be assets or pagefind — those collide
with the output directories trail writes.
The config #
Every product needs a trail.toml, and all four keys are required:
# pekit.product/trail.toml
= "pekit"
= "pk"
= "#22c55e"
= "The recipe-driven build and packaging tool — declarative recipes in; built, tested, packaged software out."
| Key | Meaning |
|---|---|
title | The product's display name, used everywhere the product is named. Unlike other containers, this is not derived from the slug — a product always states it. |
monogram | A very short string — usually two characters — shown on the product's tile, on the front-page card and at the top of the product page. Initials or a shortened name. |
color | A #rrggbb hex color. Any other form is a build error. |
description | One sentence, shown on the front-page card, under the product's name on its own page, and in llms.txt. It is also the product page's meta description. |
One optional key, inline_ref, claims phrases that auto-link to the product
page wherever they appear in prose; see
Inline references.
An icon #
Another optional key, icon, names an SVG file beside the product's
trail.toml. The icon takes the place of the monogram tile on the front-page
card, in the products menu and at the top of the product page:
# pekit.product/trail.toml
= "pekit.svg"
The icon is drawn at the tile's size with no tile behind it, so a mark that
wants a box draws its own. Where the SVG uses currentColor, it takes the
tile's color, which follows the product's color and the reader's theme. A
multi-colored icon keeps its own colors. The monogram is still required: it
is what a tree without the icon shows.
The file's root element must be <svg> with
xmlns="http://www.w3.org/2000/svg", and it must not have an id: trail
gives it one so that pages can draw it with <use>. The build publishes the
file once, at /assets/icons/<slug>.svg, and every page refers to it there.
When trees merge, any of them can set a product's icon, and trees that set
it must have identical SVGs. A component tree can leave the icon to the site
that merges it, and its own standalone build shows the monogram instead.
What the color does #
color is the product's accent, and by default it displaces the site accent
on every page belonging to that product: card borders and hover states, the
tile, sidebar highlights, heading numbers, RFC-2119 keywords, focus rings.
Setting product_theming = false in the root trail.toml turns this off
site-wide, and everything tints from the site accent instead. Products still
keep their monogram and card, they stop coloring their pages. See
Theming.
What a product contains #
A product directory holds its trail.toml and nothing but grouping
directories:
- Anthologies
(
.antho) — a titled landing page with its own children, for products big enough to need a second level. - Topics (
.topic) — a set of articles read in any order. The everyday container. - Books (
.book) — a formal, ordered document with a cover page, numbered sections and appendices. - Shelves (
.shelf) — a titled heading grouping some of the above on the product page. No URL segment of its own.
Articles, images, and .link files can not sit directly in a product
directory; they live inside topics and books. A product with nothing in it is
legal and renders an empty landing page.
Small products go straight to topics:
pekit.product/
├── trail.toml
├── 1--getting-started.topic/
├── 2--recipes.topic/
├── 3--running.topic/
└── 4--reference.topic/
Large ones add a layer:
peios.product/
├── trail.toml
├── 1--security-fundamentals.antho/
├── 2--using-peios.antho/
├── 3--advanced-peios.antho/
├── 4--developing-for-peios.antho/
└── 5--peiso.antho/
Both shapes are ordinary. Reach for an anthology when a product's topic list has grown long enough that readers have to hunt through it.
The product page #
Every product gets a landing page at /<slug>, built from the config and its
children:
- A hero with the monogram tile or icon, the title and the description.
- A "Documentation" section listing every child as a card. Anthologies and books get a card with their description; topics get a card listing their articles — all of them when there are four or fewer, otherwise the first three and a "See all N articles" link — with a count and the topic's total reading time.
- Each shelf becomes a subheading above its own row of cards. Runs of items outside any shelf render as an untitled row, in place.
Ordering #
Products have no order prefix. They sort by the root trail.toml's featured
list — in that list's order — and then everything not listed, by title.
# learn/trail.toml
= ["peios", "pekit", "provium", "universal-directory", "trail"]
The front page shows only featured products. An unfeatured product is still
built, searchable, linkable, and listed in the documentation menu. Naming a
product that does not exist in featured is a build error. A product on a
root shelf is named by its slug alone, and appears under its shelf's heading
in both the menu and the front page.
Roll-ups #
A product totals up what is beneath it. Its reading time is the sum of every
article's, and its updated date is the most recent updated: in the whole
product. Anthologies, topics, books, and chapters do the same at their own
level. See
Articles and frontmatter.
When to add a product #
A product is a heavy division: its own color, its own landing page, its own URL prefix, and a separate card on the front page. Add one when readers would go looking for the subject by name and would not expect to find it filed under something else.
Within a single product, the lighter divisions — anthologies for a second level of landing pages, shelves for a heading, topics for a set of articles — are almost always the better answer.
Anthologies and Shelves
Trail / Structuring a Site
Once a product has more than a handful of topics, its landing page becomes a wall of cards. Trail offers two ways to break that up, and the difference between them is exactly one thing: whether the grouping gets a page of its own.
| Item | URL segment | Page | Sidebar | Nests |
|---|---|---|---|---|
Anthology (.antho) | yes | its own landing page | — | at the site root, in products and anthologies |
Shelf (.shelf) | no | no — a heading on its parent's page | — | at the site root, in products and anthologies, never in a shelf |
Reach for a shelf when the topics belong together but readers should still see them all at once. Reach for an anthology when the group is big enough to deserve its own front door.
Anthologies #
An anthology is a directory named <order>--<slug>.antho. It has a landing
page at its own URL, listing everything inside it exactly as a product page
lists its own children.
peios.product/
├── trail.toml
├── 1--security-fundamentals.antho/ → /peios/security-fundamentals
│ ├── trail.toml
│ ├── 1--identity.topic/ → /peios/security-fundamentals/identity
│ └── 2--pgss.book/ → /peios/security-fundamentals/pgss
└── 2--using-peios.antho/ → /peios/using-peios
Its trail.toml requires two keys:
# 1--security-fundamentals.antho/trail.toml
= "Security fundamentals"
= "How Peios decides who may do what: identity, tokens, and the two gates every request passes."
title is the heading and the breadcrumb; description is the standfirst on
the page, the text on the card that links to it from the product page, and the
entry in llms.txt. The optional inline_ref key claims phrases pointing at
this anthology's page; see
Inline references.
An anthology can contain anthologies, topics, books, and shelves — the same set a product can contain. Anthologies nesting inside anthologies is legal and unbounded, and each level adds a URL segment:
/peios/developing-for-peios/apis/filesystem/open
└─ anthology ──────┘ └ antho ┘ └ topic ─┘ └ article
In practice two levels is plenty. Deeper than that and readers stop being able to guess where anything lives.
The anthology page #
The page mirrors a product page one level down: a breadcrumb trail back to the product (and through any parent anthologies), the title, the description, and a "Topics" section of cards. Nested anthologies and books get a description card; topics get a card listing their articles.
Shelves #
A shelf is a directory named <order>--<slug>.shelf. It is presentation only:
a shelf contributes no URL segment, has no page, and never appears in a
breadcrumb. Its whole job is to put a subheading above a row of cards on the
page it sits in.
peios.product/
└── 3--tooling.shelf/ (no URL of its own)
├── trail.toml
├── 1--pekit.topic/ → /peios/pekit
└── 2--provium.topic/ → /peios/provium
Note the URLs: the topics live directly under the product, exactly as they would if the shelf directory were not there.
Its trail.toml is optional and carries at most a title:
# 3--tooling.shelf/trail.toml
= "Tooling"
Without one, the title is derived from the slug — 3--tooling.shelf becomes
"Tooling" anyway, so most shelves need no config at all. A shelf can not
declare inline_ref: it has no page to link to, so the phrase would have
nowhere to land. Declare it on the shelf's items instead.
How shelves render #
On the parent's page, children render in order. A run of items outside any shelf renders as an untitled row of cards; each shelf renders as its title followed by its own row:
Documentation
[ Getting started ] [ Concepts ] ← loose items, no heading
Tooling ← shelf title
[ pekit ] [ provium ]
Specifications ← another shelf
[ PGSS ] [ PCDS ]
Because a shelf's items share their parent's URL space, their slugs must be
unique across the whole parent — two shelves cannot both contain a
getting-started topic, since both would want /peios/getting-started. Trail
rejects that at build time.
The rules #
- A shelf can sit in a product or an anthology, where it contains anthologies, topics, and books.
- A shelf can sit at the site root, where it contains products and root anthologies; see below.
- A shelf can never contain another shelf. Nested headings on a card grid are not a structure worth having; if you need the second level, use an anthology.
- A shelf directory holds
trail.tomland subdirectories only — no articles, no images.
Choosing #
Start flat. A product with four or five topics needs neither of these.
When the list gets long, ask whether the groups are worth a page. "Tooling" as a heading over two topic cards is a shelf. "Security fundamentals" — nine topics, two specifications, and a description worth reading — is an anthology.
The cost of an anthology is a URL segment on every page beneath it and one more select for the reader. The cost of a shelf is nothing at all, which is why it is usually the right first move.
Use an anthology at the site root #
A <slug>.antho directory can also sit at the site root. It needs the same
title and description as a nested anthology, but has no order prefix.
Its URL starts at /<slug>, without a product directory above it.
Use a root anthology when related documentation belongs in one collection without separate product branding. Component repositories can contribute pages to the same collection through merged trees.
Use a shelf at the site root #
A shelf at the site root groups products and root anthologies under a
heading. It takes the same <order>--<slug>.shelf name and optional
trail.toml as any other shelf, and it adds no URL segment:
learn/
├── trail.toml
├── peios.product/ → /peios
└── 1--tools.shelf/ (no URL of its own)
├── pekit.product/ → /pekit
└── provium.product/ → /provium
A root shelf holds only *.product and *.antho directories, plus its
trail.toml. Collections inside it keep their slugs, their URLs, and their
place in the root featured list.
The heading appears in two places:
- The Documentation menu in the site header lists every collection. Collections outside any shelf come first. Each shelf follows in order under its title.
- The front page still shows only featured collections. A featured collection on a shelf appears under that shelf's title. A shelf with no featured collections does not appear on the front page.
Within each group, collections keep the usual order: the featured list
first, then everything else by title.
A merged tree can use root shelves too. Shelves with the same slug combine and need the same order and title. A collection that appears in several trees must be on the same shelf in each of them, or outside every shelf in each of them.
Topics and Folders
Trail / Structuring a Site
A topic is a set of articles on one subject, read in any order. It is the container most pages live in, and the one to reach for unless you specifically need a book.
"Getting started", "Concepts", "Configuration", "Reference" — those are topics. The reader arrives at one of the articles from search or a link, reads it, and moves on; the sidebar is there for when they want to see what else is nearby.
The directory #
A topic is a directory named <order>--<slug>.topic, sitting in a product, an
anthology or a shelf. Its articles are the .md files inside it:
4--reference.topic/ (the topic; no page of its own)
├── trail.toml optional
├── 100--recipe-format.md → /pekit/reference/recipe-format
├── 200--supporting-files.md → /pekit/reference/supporting-files
└── 300--cli.md → /pekit/reference/cli
The 4 orders this topic among its siblings; reference is the URL segment.
Articles carry the same <order>--<slug> grammar, and their order prefixes
decide reading order — the sidebar, the previous/next links, and the order
they appear in the topic's single-page view.
Numbering in hundreds is the convention across this site. It is not a rule —
1--, 2--, 3-- works identically — but it means you can insert 150--
between two articles without renaming anything.
The config #
A topic's trail.toml is optional, and holds at most two keys:
# 4--reference.topic/trail.toml
= "Reference"
Without it, the title is derived from the slug: 4--reference.topic becomes
"Reference", 2--writing-tests.topic becomes "Writing Tests",
3--working-with-the-registry.topic becomes "Working with the Registry".
Write the file when that derivation is wrong — an acronym, a proper noun,
unusual casing — or when the topic needs inline_ref phrases, which claim
text that should auto-link to the topic's first article. See
Inline references.
A topic has no page #
This is the one surprising thing about topics. There is no page at
/pekit/reference — the topic is not a destination, it is a grouping.
That has three consequences:
- A topic appears as a card on its product's or anthology's page, listing its articles (all of them when there are four or fewer, otherwise the first three plus a "See all" link) with a count and its total reading time.
- Links land on the first article. Every surface that shows a topic — its card heading, its "See all" link, the sidebar heading on an article page — points at the topic's first article in reading order.
- A topic is not a
~linktarget.~pekit/referenceresolves nothing, becausereferenceis not the last segment of any page's path. Link to the article you mean:~pekit/reference/cli.
What does exist at the topic's path is its single-page view:
/pekit/reference/print renders every article in the topic as one long page,
and /pekit/reference/print.md is the same thing as markdown. See
The output surface.
Subfolders #
A topic that has grown past a comfortable sidebar can group runs of articles
into subfolders — plain <order>--<slug> directories, with no type
suffix:
2--concepts.topic/
├── 100--objects-and-identity.md → /ud/concepts/objects-and-identity
├── 200--the-schema-model.md → /ud/concepts/the-schema-model
└── 300--replication/ a subfolder
├── trail.toml optional
├── 100--topology.md → /ud/concepts/replication/topology
└── 200--conflicts.md → /ud/concepts/replication/conflicts
A subfolder:
- adds a URL segment, unlike a shelf;
- has no page of its own, like a topic — links from the sidebar open its first article;
- renders as a collapsible group in the sidebar, expanded automatically when the article being read is inside it;
- can hold
trail.toml, articles,.linkfiles, and images — but not another subfolder. Subfolders are exactly one level deep. A topic needing more nesting than that is either two topics or a book.
Its optional trail.toml takes the same title and inline_ref keys a
topic's does, and its title derives from its slug the same way.
An empty subfolder is tolerated and not shown, so you can create the directory before its articles exist.
The sidebar #
On an article page, the sidebar shows the article's own topic: the topic title (linking to its first article) above the topic's contents in reading order, with subfolders as collapsible groups and the current article marked. It shows one topic — not the whole product — because the topic is the unit a reader is working within.
Below it, "On this page" lists the article's own h2 and h3 headings, and
highlights the one in view.
Reading order and the pager #
The prev/next links at the foot of an article step through the whole topic in reading order, subfolder contents flattened in place. The last article of one topic does not lead to the first of the next; the pager is a topic-local device.
Topic or book #
| Use a topic when | Use a book when |
|---|---|
| Articles can be read in any order | The document is read in order, or cited by section |
| No page needs to say "§2.4" | Sections need stable numbers |
| Grouping is for navigation | The whole thing is one document with a cover |
| One level of subfolders is enough | Nesting goes deeper than two levels |
Almost all documentation is topics. Books are for specifications, formal references, and manuals — see Books.
Books
Trail / Structuring a Site
A book is a document read in order and cited by section: a specification, a formal reference, a manual. Where a topic is a set of related pages, a book is one document that happens to be split across pages.
Books get three things topics do not: a cover page, stable section numbers derived from the directory structure, and appendices.
The directory #
A book is a directory named <order>--<slug>.book, sitting in a product, an
anthology or a shelf:
1--pgss.book/ → /demo/pgss (the cover)
├── trail.toml
├── 1--introduction.md §1 → /demo/pgss/introduction
├── 2--logon/ §2 a chapter
│ ├── trail.toml
│ ├── 1--overview.md §2.1 → /demo/pgss/logon/overview
│ └── 2--flow.md §2.2
└── a1--references.md Appendix A
Its trail.toml requires a title and a description:
# 1--pgss.book/trail.toml
= "Peios Generic System Standards"
= "PGSS"
= "Cross-platform system standards from the Peios Project"
| Key | Meaning |
|---|---|
title | Required. The full name, shown on the cover and in cards. |
description | Required. The standfirst on the cover, the card text, and the llms.txt entry. |
short | Optional. An abbreviation — usually an acronym — used where the full title will not fit: the sidebar heading, the pill on the book's card, and the line above the title on the cover. |
inline_ref | Optional. Phrases that auto-link to this book, and which can carry a § section suffix in prose. See Inline references. |
Section numbers come from the directory names #
This is the part worth reading twice. A book's section numbers are its order prefixes, joined with dots along the path from the book root:
2--logon/ → §2
1--overview.md → §2.1
3--errors/ → §2.3
1--codes.md → §2.3.1
Two consequences follow:
- Number books from 1, not 100. The hundreds convention used for
topic articles would produce
§100 and §200. In a book the prefix is the published section number, so
1--,2--,3--is what you want. - Gaps show through, on purpose. If
2--is deleted the book goes §1, §3 — because in a specification, section numbers are addresses. Renumbering to close a gap silently invalidates every citation anyone has ever written; leaving the gap is the honest outcome. Renumber deliberately, or not at all.
Inside an article, h2 and h3 headings continue the numbering as real text:
in §2.1, the first h2 is §2.1.1 and its first h3 is §2.1.1.1. Headings
deeper than h3 are not numbered. The numbers are rendered into the heading
itself rather than drawn with CSS counters, so they can be searched, selected
and copied.
Chapters #
A chapter is a plain <order>--<slug> directory — no type suffix, exactly
like a topic subfolder —
except that chapters can nest as deeply as the document needs.
A chapter:
- contributes a URL segment and a section number;
- has no page of its own — links to it open its first article;
- must contain at least one article, somewhere beneath it. An empty chapter is a build error, because it would appear in the contents as a number leading nowhere;
- Takes an optional
trail.tomlwithtitleandinline_ref, with the title otherwise derived from the slug.
Appendices #
An entry whose order is written a<N>-- is an appendix: lettered instead
of numbered, and sorted after every numbered sibling at its level.
1--pgss.book/
├── 1--introduction.md §1
├── 2--logon/ §2
├── a1--references.md Appendix A
└── a2--glossary/ Appendix B
└── 1--terms.md §B.1
- Letters run
A,B, …Z,AA,AB, and so on. - The numbering is by
a<N>order, not position:a1--is A,a2--is B. Appendix numbering starts ata1;a0--is an error. - Appendices work at any level, not the book root. An appendix chapter inside a numbered chapter gives §2.A, and its articles §2.A.1.
- Where the entry itself is displayed — the sidebar, the contents — it is labeled "Appendix A" in full. In section references it is the letter.
The cover page #
A book's URL is its cover: the product and anthology breadcrumbs, the short
name if it has one, the title, the description, and the book's total reading
time and last-updated date. The contents are the sidebar tree beside it — the
whole book, chapters as collapsible groups, section numbers on every entry.
The tree remembers which chapters you opened, per book, as you move between pages.
Frontmatter is different inside a book #
Book articles use a reduced frontmatter set. title: is still required;
description:, related:, inline_ref:, updated:, and reading_minutes:
all still work.
type: is an error inside a book. The concept/how-to/reference taxonomy
describes how to approach a page, and inside a formal document that question
is already answered — you read it in order. Trail rejects the key rather than
letting it sit there meaning nothing.
Citing sections #
Books are the reason inline references exist. A book that claims a phrase can be cited by section from anywhere in the site:
"PGSS" links to the book; "PGSS §2.1" links to the exact section, resolving
through the book's index of section numbers — including numbers that belong to
a heading inside an article, not to the article itself. Within a book's own
pages, a bare §2.1 resolves the same way against the surrounding book.
Because a section number is an address, this is where the "gaps show through" rule earns its keep.
When a book is the wrong answer #
A book is a commitment: numbered sections that readers can cite, an order that means something, and a cover page. Most documentation is not that. If your sections would never be cited by number, and the pages can be read in any order, you want a topic.
Creating Link Aliases
Trail / Structuring a Site
Some pages belong in two places. A "Signing and provenance" article that lives in pekit's Running topic is also the page a reader of the security anthology goes looking for; a specification's terminology section is also an appendix of the manual next to it.
A .link file places an existing page at a second location. The content
is not copied — it is the same article, rendered again at a second URL, with
its canonical URL still pointing at the original.
Complete the task #
-
Choose an existing article as the alias target and a second navigation location for it.
-
Create an ordered
.linkfile there using the target syntax below. -
Run
trail build --strictfrom the site root to validate the target and sibling order. -
Check that the alias appears at the intended navigation location and displays the target article.
Writing one #
A link is a file named <order>--<slug>.link, holding TOML:
# 3--signing.link
= "~pekit/running/signing-and-provenance"
= "Signing and provenance"
| Key | Meaning |
|---|---|
target | Required. A ~ page reference, in exactly the grammar body links use. It must start with ~. |
title | Optional. The title the aliased page carries here. Without it, the title is derived from the link's own slug. |
The <order>--<slug> prefix works exactly as it does for an article: the
order places the alias among its siblings, and the slug becomes its URL
segment. The alias does not inherit the target's slug, its order, or its title — it is a new entry in a new place that happens to render the target's body.
Where a link can live #
.link files sit wherever articles sit: in a topic, in a topic subfolder, in
a book, or in a book chapter. They can not sit in a product, an anthology or a
shelf.
What each can target:
| In a | Can target |
|---|---|
| Topic | an article, or a whole topic subfolder |
| Topic subfolder | an article |
| Book or chapter | an article |
Aliasing a subfolder from a topic clones the entire folder into that topic's URL space — every article in it becomes an alias of its own original, under the new folder's slug. It is the one case where a single link file produces more than one page.
A link can never target another link. That would make the canonical chain ambiguous, so trail rejects it.
What the alias page is #
The aliased page renders exactly like the original: same body, same images, same headings. What differs:
- Its URL and title are the link's, not the target's.
- Its canonical URL is the original's. Search engines are told which of the two URLs is the real one, so the duplicate does not compete with it.
- It is not in the search index. Searching finds the original; the alias exists for people navigating the tree.
- It claims no
inline_refphrases. The original keeps them — a phrase must have exactly one destination. - "Edit this page" points at the original's source file, because that is the file to edit.
- Inside a book, an alias gets a section number from its own order prefix like
any other entry, can be an appendix (
a<N>--), and carries notype:ordescription:— book entries never do.
Example #
Pekit's signing article lives in its Running topic. The security anthology wants it too:
pekit.product/3--running.topic/
└── 600--signing-and-provenance.md → /pekit/running/signing-and-provenance
peios.product/1--security-fundamentals.antho/4--supply-chain.topic/
├── 100--overview.md
└── 200--pekit-signing.link → /peios/security-fundamentals/supply-chain/pekit-signing
# 200--pekit-signing.link
= "~pekit/running/signing-and-provenance"
= "Signing in pekit"
Both URLs work. Both show the same prose. Search returns the pekit one. Editing either takes you to the same source file.
When not to use one #
An alias is right when one piece of writing genuinely belongs in two navigational places. It is the wrong tool for:
- A cross-reference. If you want to point at another page, write a
~linkin the prose, or add it to the article'srelated:list. - A page that should differ between the two locations. An alias is the same article; there is no way to vary it. Write two articles.
- A rename. Aliases are not redirects — the old URL still has to exist as
a
.linkfile forever. If a page has moved for good, move it and fix the links; trail will tell you which ones broke.
Merging Source Trees
Trail / Structuring a Site
A merged site combines documentation kept in separate repositories. Each repository owns its pages, while matching containers provide one navigation structure. Use this when a component's documentation belongs beside other components' pages in the published site.
Before you start #
- Give each tree a valid Trail layout.
- Agree on shared container slugs, orders, and metadata.
- Give every article and alias one source owner.
Combine the trees #
-
Choose the site whose configuration controls the published result. This is the primary tree.
-
Add a
[[merge]]table to its roottrail.toml. Place tables after the file's plain keys. For example, this table includes a component's docs:[[]] = "../../authd/docs/learn"The path is relative to the primary root, not the working directory. To fetch the tree from its repository instead, see Fetch trees from their repositories.
-
Repeat the ancestor directories in each contributing tree. For example, two repositories can each contain this structure:
peios.antho/ trail.toml 100--accounts-and-sign-in.shelf/ 100--local-accounts.topic/Put each repository's articles inside its topic directory. Trail merges the anthology, shelf, and topic into one collection at
/peios. The shelf adds a heading without adding a URL segment. -
Give repeated containers identical metadata. The one exception is a product's
icon, which only one tree needs to set; see Products. A root anthology needstitleanddescriptionin itstrail.toml. For example:= "Peios" = "Using and developing the Peios operating system."Matching containers must also use the same type and order. Trail does not choose one repository's title, description, or reference claims over another's. See
trail-source(5)andtrail.toml(5)for the full rules. -
Build the primary tree with strict validation:
Check the result #
Open the generated site. Confirm that shared containers appear once, pages from every tree appear in reading order, and cross-tree links resolve. Follow an edit link to check that it opens the page's owning repository.
A duplicate article, alias, or image destination is an error, even when both files have identical contents. Remove the duplicate source or choose a separate slug. Use a link alias when one article belongs in two navigation locations.
Different items at the same level need different order numbers. Shelves share their parent's URL space, so moving a topic into another shelf does not make a duplicate topic slug distinct.
Choose a root collection #
Use <slug>.product for documentation that needs product branding. Use
<slug>.antho for a collection that needs a title and description without
product branding fields. Both appear in navigation and support featured.
A root anthology has no order prefix; its children use the usual prefixes.
Both root types can combine contributions. Matching nested anthologies, shelves, topics, topic folders, books, and chapters combine recursively. An anthology and a product with the same root slug conflict. A merge does not convert one container type into another.
A tree's root can also hold root shelves. Shelves with the same slug combine and need the same order and title. A collection contributed by several trees must sit on the same shelf in each, or outside every shelf in each.
Keep source ownership #
Articles and images retain their original filesystem locations. Relative
image paths resolve beside the article, including in aliases. An edit link
uses the source tree's edit_url and a path relative to that tree. A tree
without edit_url does not inherit the primary's template.
Each tree keeps its declared attachments and passthrough files. Attachment IDs are unique across the site. For overlapping passthrough paths, the primary wins, followed by the first tree listed.
Plugins run from the tree that configures them. Each block's file path remains relative to the tree that owns the article. For duplicate plugin names, the primary wins, followed by the first tree listed.
The primary controls site presentation, navigation, and featured
collections. A merged tree's own [[merge]] entries are not followed. List
every required tree in the primary configuration.
Fetch trees from their repositories #
Name a tree's Git repository with repo, and its directory inside the
repository with dir. Trail then fetches the tree itself, so a build
machine needs only the primary tree:
[[]]
= "https://github.com/peios/authd"
= "docs/learn"
= "../../authd/docs/learn"
When path names an existing directory, Trail uses that local checkout.
Otherwise it fetches the tip of the repository's default branch. Set
branch to fetch another branch. path is optional; without it, every
build fetches the tree.
Trail runs git with the credentials it already has, so private
repositories work wherever git can read them. Trail turns off
git's terminal prompt, so a repository it cannot read fails the build
instead of waiting for a password. A fetch keeps only
dir and the repository's root files, checked out under
.trail-cache/repos/ in the primary root. A later build fetches again only
when the branch has moved, and transfers only what changed. trail serve
fetches once when it starts and does not watch fetched trees.
A tree whose plugins read files outside
dir needs the whole repository. Set sparse = false to check out all of
it. The first fetch of a large repository can take several minutes; keep
.trail-cache/ between builds so later fetches stay small.
A tree from a GitHub repository gets edit links to that repository unless
its own trail.toml sets edit_url. For a local checkout, the branch in
those links is branch, or the default branch the checkout's origin
reports.
Build a component's docs separately #
Add a valid root trail.toml to build a component's tree on its own. A tree
without that file can contribute content but cannot build independently.
Links to pages supplied by another tree require the combined build. For a
partial preview, build without --strict, or pass --allow-dangling-links.
Use the combined strict build to validate those references before publishing.
Serve the combined site #
Run trail serve from the primary root. It watches all local merged trees
and rebuilds when their content changes. Dot-entries and each tree's dist/
directory are excluded from the content scan.
Writing Articles and Frontmatter
Trail / Writing
An article is a single .md file named <order>--<slug>.md: a YAML
frontmatter block, then markdown.
- -
The frontmatter is required and must be the first thing in the file: a line of
exactly ---, the YAML, and a closing ---. A file that does not start with
---, or whose block is never closed, is a build error. So is any key not
listed below — a typo'd descripton: fails the build rather than silently
doing nothing.
Complete the task #
-
Choose a topic or book in an existing site for the article.
-
Create a Markdown file using the order and slug conventions in
trail-source(5). -
Add the title and description frontmatter. In a topic, also choose the page type; omit that field in a book.
-
Write the article body after the closing frontmatter delimiter.
-
Run
trail build --strictfrom the site root and check the rendered title, description, and related links.
The keys #
The field and rule reference is in trail-frontmatter(5).
The title field #
The only key every article must have, in topics and books alike. It is not derived from the slug — unlike a topic or chapter title, an article states its own.
The type field #
Required on every article in a topic, and rejected on every article in a book.
Trail does not constrain the value or display it on the page; it is carried
through to site.json for tooling that wants to filter by it. What it is
really for is the author: deciding whether a page is a concept (explaining
how something works), a how-to (walking through a task) or a reference
(exhaustive, looked-up rather than read) is a genuinely useful discipline, and
pages that cannot answer the question are usually two pages.
Inside a book the question is already answered — a specification is read in order — so trail rejects the key rather than let it sit there meaning nothing.
The description field #
Optional, but write one. It becomes:
- The page's
<meta name="description">andog:description, which is what search engines and chat apps show; - The standfirst line in the page's markdown mirror;
- The
descriptionfield insite.json.
It is not displayed on the page itself, and it is not the in-site search snippet — Pagefind builds those from the body text around the match.
Build with --strict to make a missing description a
build failure. Alias pages are exempt, since the original carries it.
The related field #
A list of page references, in the same grammar body links use but without
the leading ~:
related:
- pekit/running/invocation
- peios/package-management/overview
They render as a "Related Content" list under the article, and they appear in
the page's markdown mirror and in site.json. Resolution is as strict as a
body link: an ambiguous reference always fails the build, and a missing one
fails unless --allow-dangling-links is set, in which case it warns and drops
from the list.
inline_ref #
Phrases that should become links to this article wherever they appear in the site's prose:
inline_ref:
- PCDS GUID
- PCDS GUIDs
Every occurrence in ordinary prose, anywhere on the site, links here — except on this page itself. Phrases are claimed site-wide and exclusively; two pages claiming the same phrase is a build error. See Inline references.
The updated field #
An ISO date, and validated as one — 2026-05-01, not May 2026 and not
01/05/2026.
updated:
It shows in the page's meta line, and it becomes the page's <lastmod> in
sitemap.xml. It is deliberately manual: file modification times are noise (a
whitespace fix is not an update, and a checkout rewrites them all), and trail
does not read git history. An article with no updated: does not show one.
reading_minutes #
Trail estimates reading time from the body's word count at 200 words a minute, rounded up, with a floor of one minute. Code blocks count — they are read, differently.
Set reading_minutes: when the estimate is wrong: a dense reference table
reads far slower than its word count suggests, and a page that is mostly a
long code listing far faster.
reading_minutes: 30
Roll-ups #
Reading times and dates add up the tree. A subfolder totals its articles; a topic totals its articles and subfolders; a book totals its chapters; an anthology totals its topics and books; a product totals everything in it.
- Reading time is the sum, so a book's cover can say how long the whole book takes and a topic card can say how long the topic is.
updatedis the most recent date anywhere beneath, so a container reflects its freshest page.
Roll-ups are computed after .link aliases are resolved, so an aliased
article counts in the totals of the place it was linked into.
The body #
Everything after the closing --- is CommonMark
with GitHub extensions: tables, strikethrough, footnotes, and
> [!NOTE]-style admonitions.
On top of that, trail adds:
~pagereferences — link by page identity instead of URL.- Co-located images —
beside the article, with dimensions filled in and captions turned into figures. - Syntax-highlighted code blocks with copy buttons.
- Tab groups and mermaid diagrams.
- Inline references,
§section citations, and RFC-2119 keyword highlighting.
A few things happen to headings automatically: h2 and h3 become the "On
this page" list, every heading gets a stable id and a permalink anchor, and
inside a book they carry their section numbers as real text. Ids come from the
heading text, with a numeric suffix if two headings on a page would otherwise
collide.
Tables are wrapped in their own horizontally-scrolling container, so a wide table never makes the whole page scroll sideways.
Naming and ordering #
The filename is not decoration:
200--quick-start.md
│ └── the URL segment, and what you write in a ~link
└── the sort key among siblings — never shown, never in a URL
Two files sharing an order in the same directory is an error. Numbering in hundreds leaves room to insert later; inside a book the prefix is the published section number, so number from 1 there instead.
print is a reserved slug — every container publishes a /print page — so
100--print.md is rejected.
Writing Links and References
Trail / Writing
Trail links pages by identity, not by URL. Instead of writing a path that
breaks the moment a page moves, you write a ~ reference naming the product
and enough of the page's slugs to be unambiguous:
Reorganize the tree — move that topic into an anthology, wrap it in a shelf, renumber it — and the link still resolves. Delete the target, and the build fails and tells you every page that pointed at it.
Complete the task #
-
Find the destination page in the source tree and identify its product, grouping, and slug.
-
Write a descriptive link label and a qualified
~reference using the examples below. -
Add a fragment only when linking to a specific heading or explicit anchor.
-
Run
trail build --strictfrom the site root. Resolve reported missing or ambiguous targets, then check the destination in the built site.
The grammar #
~<product-slug>[/<segment>]…[#<fragment>]
- The first segment is always a product slug. There is no relative form and no site-wide search; every reference says which product it means.
- The remaining segments match the end of a page's path. Trail compares them against each page's slugs — the anthology slugs, the topic slug, any subfolder or chapter slugs, and the page's own — and matches if your segments are the tail of that list.
- Exactly one page must match. Zero or several is an error.
- A fragment can follow, and is appended to the resolved URL:
~pekit/reference/cli#global-flags. It is checked too: the target article must define that anchor — a heading id, a[*name]citation anchor, or an id written in raw HTML — or the link is broken. Fragments on product and anthology pages, which have no body, are not checked.
The rule of thumb is: write the shortest thing that is unambiguous, and add segments from the left only when you have to.
A worked example #
Given this page:
/peios/security-fundamentals/identity/tokens/issuing
└ anthology ───────┘ └ topic ┘ └folder┘ └page┘
all of these resolve to it:
~peios/issuing
~peios/tokens/issuing
~peios/identity/tokens/issuing
~peios/security-fundamentals/identity/tokens/issuing
~peios/issuing is the one to write — until a second page in peios is also
called issuing, at which point that reference becomes ambiguous, the build
fails, and you add a segment.
Note that the deeper segments are for disambiguation only. A chapter or subfolder slug can appear in a reference even though it is not a page you could link to on its own.
What can be a target #
| Item | Targetable | Reference |
|---|---|---|
| A product | yes | ~pekit |
| An anthology | yes | ~peios/security-fundamentals |
| A book cover | yes | ~peios/pgss |
| An article | yes | ~pekit/reference/cli |
| A topic | no | link to an article in it |
| A topic subfolder | no | (except as a .link target) |
| A book chapter | no | link to an article in it |
| A shelf | no | it has no page at all |
Topics, subfolders and chapters have no page of their own, so there is nothing for a reference to land on. Link to the article you actually mean.
Ordinary links still work #
A ~ at the start of a destination is what makes it a reference. Everything
else is left alone:
Root-relative links are the escape hatch for the handful of URLs that are not
pages — /print views, /llms.txt, /site.json. They are not checked, so
they are also the way to ship a broken link. Prefer ~ wherever the target is
a page.
A same-page fragment is checked, against the page's own heading ids,
citation anchors and raw-HTML ids. Heading ids are derived from the heading
text — lowercased, every run of non-alphanumerics collapsed to one hyphen, so
## vm:run(cmd, opts) is #vm-run-cmd-opts — and a repeated heading gets
-2, -3, … appended. Inside a /print bundle the link is namespaced along
with the ids it points at, so it keeps working there.
One form is always an error: a relative path, such as
../410--network-policy.md. Pages are addressed by their slugs, not their
source files, so no relative path can ever reach one; the build rejects it and
tells you to write a ~ reference instead.
~ is only meaningful in a link destination. In an
image destination it is an error, with a message
saying so: images are files, addressed relative to the article.
Where else references are used #
The same grammar appears in three other places:
# an article's frontmatter — no leading ~
related:
- pekit/running/invocation
# a .link alias file — with the ~
= "~pekit/running/signing-and-provenance"
# the root trail.toml's nav — with the ~, or an external URL
[[]]
= "Specs"
= "~specifications/pgss"
The related: list is the odd one out in dropping the ~; everything else
keeps it.
When a link breaks #
Every link in the site is checked on every build, and all the failures are reported together — one build tells you the whole story rather than stopping at the first bad reference.
Error: 3 broken links:
in article '/pekit/recipes/anatomy': link '~pekit/running/invokation' matches no page in product 'pekit'
in article '/peios/identity/sids': link '~pekti/overview' names unknown product 'pekti'
in article '/pekit/reference/cli': link '~pekit/targets' is ambiguous; candidates:
~pekit/running/commands-and-targets/targets
~pekit/reference/recipe-format/targets
There are five failure kinds, and they are not treated alike:
| Item | Means | With --allow-dangling-links |
|---|---|---|
| Unknown product | the first segment is not a product slug | warning |
| No match | nothing in that product ends with those segments | warning |
| Missing anchor | the page exists but defines no such #fragment — on a ~ reference or a same-page link | warning |
| Relative path | the destination is a file path, which no page can serve | warning |
| Ambiguous | two or more pages match | still fatal |
Ambiguity is never downgradable. A missing target is a link that does nothing; an ambiguous one is a link that goes somewhere specific and possibly wrong, and only the author knows which page was meant.
--allow-dangling-links is for the middle of a refactor, when you have moved
a hundred pages and want to see the site before fixing every reference. It is
not a setting to leave on.
References in print views and mirrors #
The single-page and markdown views rewrite references so they still work away from the site:
- In a
/printbundle, a reference to a page inside the same bundle becomes an in-document anchor, so the whole document navigates itself. A reference to a page outside it becomes an absolute URL when the site config has aurl, and stays root-relative otherwise. - In a
.mdmirror, a reference becomes the target's own.mdURL, so a reader following links through the markdown surface stays in it.
Adding Images
Trail / Writing
Images live beside the articles that use them. There is no assets
directory to maintain and no separate URL scheme to remember: drop the file in
the same folder as the .md, and reference it by name.
2--logon.topic/
├── 100--overview.md
└── logon-flow.svg
The image publishes at the URL of the directory it was found in, keeping its
own file name — here /peios/logon/logon-flow.svg. Move the folder and the
image moves with it.
Complete the task #
-
Place the image beside an article, using a supported extension and a lowercase slug filename.
-
Add Markdown image syntax with meaningful alternative text and a path relative to the article.
-
Add the variants or sizing syntax described below when needed.
-
Run
trail build --strictfrom the site root and check the image in the built page.
Referencing #
Destinations resolve relative to the article's own .md file, exactly as
an editor's markdown preview resolves them. Relative paths can climb out of a
subfolder with .., so a diagram shared by a folder's worth of articles can
sit one level up:
2--concepts.topic/
├── shared-diagram.svg
└── 300--replication/
├── 100--topology.md 
└── 200--conflicts.md 
Three kinds of destination are left exactly as written and never checked:
absolute URLs (https://…), root-relative paths (/…) and data: URIs.
A ~ reference in an image destination is a build error. ~ names pages, not
files.
Where images can sit #
Anywhere articles can sit: a topic, a topic subfolder, a book, or a book
chapter. Not in a product, anthology, or shelf directory — those hold only
trail.toml and subdirectories.
The file name must be a valid slug plus a lowercase extension:
logon-flow.svg, not Logon Flow.SVG. Recognized extensions are:
png jpg jpeg gif svg webp avif
Anything else in an article directory is an "unexpected file" error — which is
the point. A .pdf or a .xlsx sitting in a content folder is almost always
a mistake, and trail would rather say so than quietly ignore it.
Dimensions #
Trail reads each raster image's header at build time and emits real width
and height attributes:
The browser can then reserve the right space before the file arrives, so text does not jump around as images load. SVGs get no dimensions — they scale — and neither does any file whose header cannot be read.
Captions and figures #
An image with a title — the quoted string after the destination — that
sits alone in its own paragraph becomes a <figure> with a <figcaption>:
How a logon token reaches the session service
The two strings do different jobs and should say different things. The alt text describes the image for someone who cannot see it. The caption is prose everyone reads, and can say what the diagram is for.
An image without a title, or one sharing its paragraph with other text,
renders as an ordinary inline <img>.
Unreferenced images #
Only images some article actually references are copied into the output. One that nothing references prints a warning and is left out:
warning: image '/…/2--logon.topic/old-diagram.png' is not referenced by any article and was not published
A warning rather than an error, deliberately: adding the file before the article that will use it is a normal way to work. But a warning that stays warning is a file to delete.
A referenced image that does not exist is the other way round — a broken link,
fatal unless --allow-dangling-links downgrades it:
in article '/peios/logon/overview': image 'logon-flow.svg' not found (resolved relative to the article's folder)
In the other views #
Images work in the
markdown mirrors and /print bundles
too: since those serve an article's body away from its own folder, relative
destinations are rewritten to the image's published URL.
Diagrams #
For flowcharts, sequence diagrams and the like, consider a mermaid code block instead of an image file. Mermaid diagrams are text — diffable, editable, and they follow the reader's light or dark theme, which a checked-in PNG cannot.
Attachments
Trail / Writing
Declare downloads in the site root's trail.toml. Trail can copy a file or
package a directory as a .tar.gz archive. It validates the source and
references, publishes the download, and records its size and SHA-256 digest.
Declare a source bundle #
Keep the source in a dedicated directory outside the product tree:
docs/
├── trail.toml
├── download-sources/
│ └── tools/
│ ├── README.md
│ └── scripts/
└── example.product/
Add a declaration to the root configuration:
[[]]
= "example-tools"
= "Example Tools"
= "Configuration files and setup scripts."
= "download-sources/tools"
= "example-tools.tar.gz"
= "tar.gz"
= [".venv", "node_modules", ".cache", "results"]
source is relative to the declaring tree's root. The declaration makes its
top-level source directory legal there without publishing the loose files.
Each merged tree can declare its own attachments. IDs must be unique across
all trees.
exclude lists exact paths relative to the bundle directory. A directory
entry excludes its whole subtree; entries are not glob patterns. All other
files, including hidden files, enter the archive. Keep generated environments
and local output outside the bundle or list them explicitly.
Declared attachment sources are data, so trail lint does not treat their
Markdown files as documentation articles. Check bundled code and README files
with the bundle's own tools.
Trail rejects symbolic links, special files, paths outside the source tree, and sources that overlap the build output. It never executes bundled code.
Publish a single file #
Use format = "file", the default, for a PDF, configuration file, or archive
produced by another tool:
[[]]
= "example-config"
= "Example Configuration"
= "A starting configuration for the example service."
= "download-sources/example.toml"
= "example.toml"
The published bytes match the source. File attachments do not accept exclusions.
Link to downloads and metadata #
Use the exact ID in an attachment reference:
The first reference resolves to
/attachments/example-tools/example-tools.tar.gz. The second resolves to
/attachments/example-tools/metadata.json. Missing references are link
errors; --allow-dangling-links can downgrade them like other unresolved
references. Valid attachment links produce no --strict advisory warning.
Attachment links retain file URLs in Markdown exports. Print links use the configured site URL, and cache-busting copies keep their own download URLs.
The attachments product slug and passthrough output directory are reserved
when a site declares attachments. IDs and filenames start with an ASCII
letter or digit and contain only ASCII letters, digits, dots, underscores,
and hyphens. The ID index.json and filename metadata.json are reserved.
Inspect download metadata #
Each metadata file contains schema_version (1), id, title,
description, filename, url, metadata_url, format, media_type,
size_bytes, and sha256. The digest covers the published bytes, including
compression for archives. /attachments/index.json lists the same records
in ID order. These records omit local source paths.
Generated archives use application/gzip; copied files use
application/octet-stream in the metadata. The hosting server controls its
HTTP content type and download headers. Trail does not configure that server.
Rebuild bundles #
Archive entries are sorted and placed under one directory named after the
attachment ID. Trail preserves file contents and whether Unix files are
executable; other permission bits, ownership, and timestamps are normalized.
Directories and executable files use mode 0755; other files use 0644.
Empty directories are preserved. Identical inputs with the same Trail build
produce identical archives, independent of checkout location or file dates.
Content and executable-mode changes invalidate the archive cache. Unchanged
downloads retain their output modification times. Removed declarations prune
their downloads and metadata on the next successful build. trail serve
also detects changes to declared hidden inputs and executable modes.
Writing Code Blocks
Trail / Writing
Fenced code blocks work as they do in any markdown, with an info string naming the language:
Trail highlights that at build time and wraps it with a copy button:
…
fn …
Complete the task #
-
Choose a language name for the block, or
textfor unhighlighted output. -
Write a fenced code block in an article using that language name.
-
Put commands in a shell block without a prompt, and show their output in a separate
textblock. -
Run
trail build --strictfrom the site root and check the highlighting and copy button.
Highlighting is classes, not colors #
Highlighting happens once, when the site is built — there is no highlighter shipped to the browser and no flash of unstyled code.
What is emitted is class names, not inline colors: hl-keyword,
hl-string, hl-comment and so on, prefixed so they cannot collide with the
theme's own classes. Those classes resolve through the same CSS custom
properties as everything else on the page, which is why code follows the
reader's light or dark choice instead of freezing one palette into the markup.
Theming covers the tokens involved.
The copy button #
Every code block gets one. It sits in the top-right corner, appears on hover (and is always visible on touch devices), copies the block's text to the clipboard, and briefly says so.
Nothing is stripped from what it copies, so a $ prompt in a shell example is
copied along with the command. Write shell examples without prompts if you
would rather they paste cleanly.
Code blocks returned by plugins preserve whitespace-only lines, including spaces, tabs and form feeds. This also applies inside lists and blockquotes, so live file excerpts retain their content when Trail inserts the plugin output.
Which languages are highlighted #
Trail bundles syntect as its
highlighter, with the extended syntax collection from
two-face — the same
definitions bat ships, a little over two
hundred of them. The info string is matched against a syntax's name or one of
its file extensions, case-insensitively, so both rust and rs work.
Everything you are likely to reach for is covered:
bash / sh / fish / zsh asm awk cmd / bat c / c++ / c#
clojure cmake coffeescript crystal css / scss / sass / less / stylus
d dart diff dockerfile dotenv elixir elm
erlang f# f90 gd gitconfig / gitignore
glsl go / gomod graphql dot groovy haskell hcl / terraform
html http idris ini java js jq
json / jsonnet julia kotlin latex / bibtex lean
lisp llvm lua make markdown matlab nginx
nim nix objective-c ocaml odin orgmode pascal
perl php protobuf puppet purescript python qml
r racket rego robot ruby / haml / slim rust
scala solidity sql svelte swift systemverilog / verilog / vhdl
tcl toml typescript / tsx typst vim vue
wgsl xml / svg yaml zig
…alongside the config and system formats that turn up in documentation:
crontab, fstab, passwd, resolv, syslog, ssh_config, known_hosts,
.htaccess, requirements.txt, csv / tsv, manpage, strace, email.
Still absent: powershell, and the shell-session forms (console,
shell-session). A console block renders as plain text — which is usually
what you want anyway, since a $ prompt is not shell syntax.
An info string the set does not recognize is not an error and does not
fail the build: the block renders as plain escaped code, with the same
wrapper, the same copy button, and its language still recorded on it as
data-language.
The exception is an info string that opens with {name}. That is a
plugin block, expanded by a command the site
configures, and naming a plugin that is not configured is an error.
Two languages are not code at all: mermaid blocks become
diagrams, and math blocks
become equations.
The definitions' licenses ship with every build at
/assets/LICENSE-Syntaxes.txt.
Blocks with no language #
A fence with no info string renders as escaped plain text, with the wrapper and copy button intact. Use one for output, trees, and anything that is not a language:
Across this site the convention is text for that. The highlighter does not
recognize text as a language, so it renders identically to a bare fence
while reading more explicitly in the source.
Indented code blocks (four spaces) are supported too, and are treated as having no language.
Inline code #
Inline `code` is ordinary markdown and is not highlighted. It is also
excluded from inline reference matching: a
claimed phrase inside backticks stays plain text, so writing `PCDS GUID`
when you mean the literal string does not produce a link.
In the other views #
Code blocks survive into the
markdown mirrors and /print bundles as
ordinary fenced blocks with their info strings intact — the mirrors reproduce
your source, not the rendered HTML. Plugin blocks are the exception: they
appear expanded.
Writing Equations
Trail / Writing
Equations are written in TeX, in one of two forms, both of which GitHub renders the same way.
An equation on its own goes in a code block tagged math:
which renders as:
An equation inside a sentence is a code span with a dollar sign hard against each side:
which renders as: the average decays by a factor of each sample.
Each math block holds one equation. Several lines are one equation only
inside an environment that sets them out, such as align* with its & and
\\:
Complete the task #
-
Choose an inline expression or a display equation using the syntax below.
-
Write the expression in an article, keeping its delimiters balanced.
-
Run
trail build --strictfrom the site root and resolve any equation errors. -
Check that the rendered equation is legible at the page reading size.
Plain dollar signs are text #
$x$ is not an equation. Documentation is full of dollar signs that are
nothing of the kind: $PATH and $HOME, costs $5 or $10,
$dport_dev ($dport_dev. Any two of those in a paragraph would pair up into a
garbled equation, and no error would say so. The code-span form never happens
by accident, and a dollar sign needs no escaping anywhere.
What sits inside a math block or the code span is passed to TeX exactly as
written. Markdown escapes don't apply there, so \_ stays \_.
What it becomes #
Trail renders each equation to MathML, which browsers lay out natively, at build time:
- No script and no font download. An equation works in print bundles and with JavaScript off.
- The TeX stays with the equation. It is attached as an annotation, so screen readers and copying can use it.
- The Markdown mirrors keep the TeX as written. Readers of the mirror get the fence or code span, which they can render themselves.
An equation on its own is spaced like a paragraph. If it is wider than the column, it scrolls rather than squeezing.
TeX that doesn't parse #
An equation that fails to parse fails the build, as a broken link does, naming the equation and what is wrong with it:
in article '/guide/colour': equation '\frac{1}' is not valid TeX: parsing error: expected a token
Trail renders with
pulldown-latex, which covers
the commands of everyday mathematics: fractions, roots, sub- and superscripts,
\text, \left/\right, Greek letters and relations, and the align,
matrix and cases families of environments.
Adding Admonitions, Tabs, and Diagrams
Trail / Writing
Three constructs on top of ordinary markdown handle the things prose alone does badly: setting something apart, showing the same instruction several ways, and drawing.
Complete the task #
-
Choose the element that fits the content: an aside, alternative views, or a diagram.
-
Add the corresponding syntax from the sections below to an article.
-
Keep an admonition marker on its own blockquote line and close tab groups and fenced diagrams.
-
Run
trail build --strictfrom the site root and check the result in a browser.
Admonitions #
Admonitions use GitHub's alert syntax — a blockquote whose first line is a marker:
Five kinds exist, and no others:
| Marker | Renders as | For |
|---|---|---|
> [!NOTE] | Note | An aside worth knowing, not worth interrupting for. |
> [!TIP] | Tip | A shortcut or a better way. |
> [!IMPORTANT] | Important | Something a reader who skims will regret missing. |
> [!WARNING] | Warning | Something that will go wrong. |
> [!CAUTION] | Caution | Something that will go irreversibly wrong. |
The body is full markdown — lists, code blocks, links, all of it.
A blockquote whose first line looks like a marker but is not one of the five is a build error, not silently-rendered text:
unknown admonition type '[!WARN]' (expected NOTE, TIP, IMPORTANT, WARNING or CAUTION)
That is deliberate. A typo'd marker renders as a quotation with [!WARN]
sitting at the top of it, which nobody proofreading their own page ever
notices.
An ordinary blockquote — no marker — is still an ordinary blockquote.
Tab groups #
Tab groups show the same instruction several ways, so a page does not have to repeat itself per platform, per shell, or per package manager.
The grammar is three markers, each alone on its own line:
| Marker | Meaning |
|---|---|
:::tabs | Opens a group. |
:::tab <label> | Starts a tab. The label is everything after the marker. |
::: | Closes the group. |
The first tab is shown; the rest are hidden until selected. Each panel's body is full markdown, so a tab can hold code blocks, lists, admonitions and images.
Rules, all of them enforced at build time:
- A group must be closed — an unclosed
:::tabsis an error. - A group must contain at least one
:::tab, and each:::tabneeds a label. - Nothing but blank lines can appear between
:::tabsand its first:::tab. - Groups cannot nest.
:::taboutside a group, or:::with no group open, is an error.
Markers inside fenced code blocks are left alone, which is how this page can show the syntax without triggering it.
Diagrams #
A code block tagged mermaid is rendered as a diagram in the browser:
Any mermaid diagram type works — flowcharts, sequence diagrams, state diagrams, ER diagrams, Gantt charts, and the rest.
The mermaid library is a large script, so it is only shipped to pages that actually contain a diagram. A site with no diagrams anywhere never emits it at all.
The diagram is drawn in the reader's current theme, light or dark, chosen when the page loads. Switching theme afterward re-styles the rest of the page but leaves already-drawn diagrams as they were until the page is reloaded.
Diagram or image #
Prefer mermaid when the diagram is boxes, arrows and labels. It is plain text in your source: diffable, reviewable, editable by whoever is next in the file, and it follows the reader's theme.
Reach for an image when the thing is genuinely pictorial — a screenshot, a photograph, an illustration, or a diagram whose layout matters more than mermaid will let you control.
Inline References
Trail / Writing
Some terms should always be links. If there is one page explaining what a PCDS GUID is, then every "PCDS GUID" written anywhere on the site ought to point at it — and nobody wants to write that link by hand a hundred times, or notice the ninety-nine places it was forgotten.
An inline reference is a phrase a page claims. Trail then links every occurrence of that phrase in the site's prose to the claiming page, automatically.
Declaring a phrase #
Declaration is self-service: a thing declares the phrases that mean it, in its own file. There is no central glossary to maintain.
An article declares in its frontmatter:
---
title: Globally unique identifiers
type: reference
inline_ref:
- PCDS GUID
- PCDS GUIDs
---
Everything else declares in its trail.toml:
# 2--pgss.book/trail.toml
= "Peios Generic System Standards"
= "PGSS"
= "Cross-platform system standards from the Peios Project"
= ["PGSS", "Peios Generic System Standards"]
Phrases are matched literally, so plurals and alternative spellings are separate claims. List them all.
Where a phrase lands #
| Declared on | Links to |
|---|---|
| An article | that article |
| A product | the product's landing page |
| An anthology | the anthology's landing page |
| A book | the book's cover — and § can reach a section |
| A topic | the topic's first article |
| A topic subfolder | the folder's first article |
| A book chapter | the chapter's first article |
The pattern is: the declarer's own page, or — for the containers that have no page — the first article inside it. A container that declares a phrase but holds no articles to land on is a build error.
A shelf can not declare a phrase at all, since it has neither a page nor articles of its own. Declare it on the shelf's items.
Where phrases are matched #
In ordinary prose, and only there. Matching skips:
- Headings, whose ids are derived from their text;
- Link text — a phrase inside an existing link is left alone, so a deliberate link is never rewritten;
- Image alt text;
- Code blocks and inline code — writing
`PCDS GUID`when you mean the literal string produces no link; - The claiming page itself, which never links to itself.
Two more rules make matching predictable:
- Whole words only. A phrase surrounded by letters, digits, or underscores does not match. "PCDS GUIDs" does not match inside "PCDS GUIDsomething".
- Longest wins. When two claimed phrases overlap at the same position, the longer one is used — so "PCDS GUID" beats "PCDS", and a phrase does not get chopped up by a shorter one inside it.
Phrases are exclusive #
A phrase belongs to exactly one declarer, site-wide. Two things claiming the same phrase is a build error:
inline_ref phrase 'PCDS' is claimed by both book '/peios/pcds' and article '/peios/formats/pcds-overview'
That is the whole point: if two pages both want to own a term, the ambiguity is real and a reader would have been sent to the wrong one. Decide which page is the destination.
Empty phrases, phrases with leading or trailing whitespace, and phrases
containing § are also errors.
Link aliases never claim phrases —
the original keeps them.
Choosing phrases well #
Inline references are powerful in the way find-and-replace is powerful. A phrase that is too common turns the site into a sea of blue.
- Claim terms of art, not ordinary words. "PCDS GUID" is a term. "identity" is a word.
- Claim what a reader would want defined. The test is whether someone meeting the phrase mid-sentence would benefit from a link.
- Prefer the specific form. Claiming "GUID" catches every passing mention; claiming "PCDS GUID" catches the ones that mean your page.
- Remember plurals and expansions — they are separate claims, and a term claimed in only one of its forms links inconsistently, which reads worse than not linking at all.
Section citations with § #
A phrase claimed by a book can be extended with a section number in prose:
"PGSS §2.1" becomes one link to that exact section. The suffix is a single
space (or non-breaking space), the § sign, and a section label — digits,
dots, and appendix letters: §2, §2.1.3, §A, §B.2. A sentence-ending
full stop is not part of the label.
Every book carries an index of its section numbers, covering:
- articles, by their section number (
§2.1→ that article's page); - chapters, by theirs (
§2→ the chapter's first article); - headings inside articles — the
h2andh3numbers trail generates (§2.1.3→ that article, at that heading).
So a citation can be as precise as a subsection of a page.
A § label that does not resolve is a build error — with the phrase still
linked to the book, so the page is not broken while you fix it:
'PGSS §9.9' does not match any section of '/peios/pgss'
Like a broken ~link, it is downgraded to a warning by
--allow-dangling-links.
Bare § inside a book #
Within a book's own pages, a bare § reference resolves against the
surrounding book, with no phrase needed:
Unlike the phrase-qualified form, a bare § that does not resolve stays
plain text and says nothing. That is not an oversight: specifications
routinely cite sections of other documents, and a build that failed on every
"§9.9 of RFC 3986" would be unusable. The qualified form names its book and so
can insist; the bare form cannot, so it does not.
RFC-2119 keywords #
Requirement keywords are highlighted everywhere on the site, with no configuration and nothing to declare:
MUST · MUST NOT · REQUIRED · SHALL · SHALL NOT · SHOULD · SHOULD NOT · RECOMMENDED · NOT RECOMMENDED · MAY · OPTIONAL
They must be written in capitals, as RFC 2119 intends — the capitals are what distinguishes a requirement from the ordinary English word. Matching is whole-word and longest-first, so "MUST NOT" highlights as one keyword rather than as "MUST" followed by a stray "NOT", and it skips the same places phrase matching skips: headings, links, and code.
The styling is a weight and the product's accent color, not a badge. It is meant to make a requirement scannable in a page of prose, and it works in ordinary articles as well as in books.
Named Citations
Trail / Writing
A § reference reaches an article. That is usually the right size for prose —
but not for a test. A test verifies one statement, and an article holds many;
"this test covers §4.6" cannot tell you which of §4.6's nine statements is
still unverified.
A named citation is an anchor on a single statement:
Anything outside the site can now point at exactly that sentence:
// Verifies PKM *copy-up.preserves-ownership
The build collects every anchor into citations.json, so a test suite can ask
which citations nothing yet verifies.
Anchors on headings #
An anchor on a heading names the whole section:
This is usually what you want. A well-structured document already gives a behavior its own section, so the section is the citable unit, and an anchor on a heading rides the structure rather than one sentence of prose that can later be rewritten.
The marker renders inside the heading and contributes nothing to the heading's id or its table-of-contents entry, so it is safe to add to an existing heading — nothing that linked to that section breaks.
In citations.json a heading anchor is reported with "kind": "section" and
its context is the heading text; everything else is "kind": "statement". A
coverage report wants the difference: an uncovered section is a
different-sized gap from an uncovered sentence.
Reach for a statement anchor when one section states several independent rules — a table of error conditions, or a numbered list — where one name for the section would be too coarse to say which rule is untested.
An anchor is a locator #
It marks a place, not a span. [*copy-up.preserves-ownership] says "the
statement here is called this"; it does not say where that statement begins or
ends, and Trail never tries to work that out.
That is deliberate. A name is arbitrary, so nobody argues about it and nobody revises it. An extent looks like it has a correct answer — does the following clarifying sentence belong inside? the exception clause? — so it invites disagreement and revision, and every revision is churn that helps none of the things a citation is for. Overlapping and nested statements have no clean bracketing rules either.
So an anchor is a pointer, and a reader follows it and reads.
One citation, many tests #
Coverage is "does this citation have at least one passing test". It is never a one-to-one mapping.
A statement in a specification is often close to one testable behavior. In a reference manual it usually is not: an anchor is as much a way of dividing a large descriptive document into consumable chunks as it is a single assertion. Getting closer to one-anchor-one-behavior is better where it happens naturally, but it is not a requirement, and a report that assumes it will mislead.
Writing anchors #
Put the anchor at the end of the statement it names. Do it as a separate pass, after the prose is written — annotating while drafting interrupts the writing, and picking out testable statements is a different kind of attention from composing them.
A name is lowercase alphanumerics in dot- or hyphen-separated segments, starting and ending alphanumeric:
| Item | Meaning |
|---|---|
copy-up.preserves-ownership | ✅ |
mount.strata.order | ✅ |
Copy-Up.Ownership | ❌ uppercase |
copy..up | ❌ doubled separator |
.leading | ❌ must start alphanumeric |
The grammar is enforced at build rather than merely recommended: a name is what every citation greps for, so a corpus with three naming styles is a corpus where a search misses things.
A name must be unique within its book, and the build fails if one is
declared twice. Uniqueness is per book rather than site-wide — unlike an
inline_ref phrase — because names are naturally book-scoped and a citation
from outside is qualified by the book's short name anyway.
Only a book can carry an anchor. A citation is addressed through its book, so an anchor in a task-doc topic could never be cited; the build rejects it rather than leaving it silently unreachable.
Retiring one #
Delete the anchor, and grep the name to find the tests and comments that pointed at it. Do not reuse a retired name for a different statement: nothing can detect that, and every existing citation silently comes to mean something else.
How it renders #
A small superscript marker, positioned out of the text's flow so line height and wrapping are exactly as they would be without it. Selecting copies the full citation string — the thing you want in a test — rather than navigating; the link still targets the anchor, so "copy link address" and middle-select behave normally, and the page works without JavaScript.
Readers who would rather not see them at all can call
trailToggleCitations(), which persists per browser.
What the build produces #
citations.json, at the site root, listing every anchor in the corpus:
It is its own file rather than part of site.json, which is a tree of the
whole site: the consumers here want a list they can read without walking one.
context is the source block the anchor sits in, not the statement it
marks — an anchor delimits nothing. Two anchors in one paragraph get the same
context. Treat it as a label for a coverage report, and follow url when you
need the real thing.
Anchors are also left as written in the markdown mirrors, so an agent reading
print.md sees them.
Anchors in code samples stay literal #
[*name] inside a fenced block or inline code is never an anchor, which is
what lets this page show the syntax. Everywhere else, an anchor is rewritten
before the markdown is parsed — otherwise the * could pair with an emphasis
marker elsewhere in the paragraph and swallow the anchor into an <em>.
Writing Plugin Blocks
Trail / Writing
Some content is not written but derived: API reference extracted from source comments, tables generated from a schema. A plugin block asks an external command to produce that content at build time, so the page and its source can never disagree.
The fence's info string is {name}, which is how
MyST spells a directive. Trail hands
the block to the command the site configures under that name, and puts the
markdown that comes back where the fence was.
Complete the task #
-
Install or build the plugin command and confirm its version-1 process interface against
trail-plugin(5). -
Configure its command under
[plugins.<name>]in the site root configuration. -
Add a fence naming the configured plugin to an article, using the plugin's documented argument and options.
-
Run
trail build --strictfrom the site root and check that the generated content replaces the fence. -
Change a declared plugin input and rebuild to confirm that its output updates.
Writing a block #
```{name} argument
:option: value
:flag:
body
```
{name}names a plugin configured in the roottrail.toml. A{name}that is not configured is a build error, the same as a mistyped admonition marker. Otherwise it would render as a code block, and nobody notices a code block that should have been a page of reference.- The argument is everything after
{name}on the opening line. What it means is up to the plugin. - Options are
:key: valuelines at the start of the block. A flag has no value. An indented line continues the previous option's value, and a trailing\on a piece is dropped, as in reStructuredText. Giving the same option twice is an error. - The body is whatever follows the options, after one optional blank line.
A plugin block works anywhere a fenced code block does: inside list items and blockquotes, with backticks or tildes, at any fence length. To show the syntax on a page, as this one does, wrap it in a longer fence: the inner fence is then content, not a block. Indented code blocks are never plugin blocks.
An unclosed plugin fence is an error, because it would otherwise take the rest of the page as its body.
Configuring a plugin #
Plugins are declared in the root trail.toml, one table each:
[]
= ["python3", "../tools/docs/trail-kernel-doc/trail-kernel-doc", "--srctree", ".."]
command is the program and its arguments, run directly, not through a shell.
Two more keys, anchors and after, let a plugin
link to the rest of the site. A program
containing a / is a path relative to the site root and must exist. A bare
name is looked up on PATH. The working directory is the site root.
A plugin configured in a
merged tree's trail.toml treats
that tree's root as the site root throughout: its program path, working
directory, root and file are all relative to the tree, exactly as when the
tree is built alone. Its blocks can still appear on any page of the site.
Markdown can only name a configured plugin; it can never say what to run.
Building a site runs only the commands its trail.toml lists.
Plugin names are lowercase letters, digits, -, and _. The
trail.toml reference has the table's details.
What a plugin receives and returns #
Trail runs each plugin at most once per build, passing every one of its blocks on the site in a single request. A plugin with no blocks is not run at all. A plugin that cross-references its own output can therefore see everything at once: a function name in one block can link to the page where another block documents that function.
The request arrives as JSON on stdin:
The complete process and field reference is in trail-plugin(5).
The plugin answers on stdout:
Every block id must be answered exactly once, each answer with exactly
one of markdown or error. depends_on lists the files the output was
derived from, relative to the root or absolute.
A plugin that scans a directory, rather than reading files it was told about,
should list the directory as well as the files it read. A directory in
depends_on stands for the set of files beneath it, so a file added there or
removed counts as a change. Edits to those files count only through the files'
own entries.
The plugin's stderr is captured and replayed after execution, including on cache hits. Use it for diagnostic messages.
Linking to the rest of the site #
A plugin sees only its own blocks. To link to something another page defines,
such as a function documented by hand, it can ask for the site's anchors with
anchors = true in its table. Its request then carries one more field: every
page's explicit anchors, keyed by reference.
Explicit anchors are the ids written in raw HTML, <a id="…">, and
citation anchors. Heading ids are left out: Trail derives them from the
heading's words, so they change when a heading is reworded and are no basis
for generated links.
The anchors come from the pages as written, before any plugin's output is
added, so what one plugin generates never depends on another having run. To
link to targets that another plugin generates, name it in after:
[]
= ["python3", "../tools/docs/trail-kernel-doc/trail-kernel-include", "--srctree", ".."]
= true
= ["kernel-doc"]
Trail then runs kernel-doc first and adds the anchors in its output to those
kernel-include receives. Each plugin runs after every plugin its after
names. Independent plugins can run together in bounded groups; their results
and diagnostics retain dependency order, then name order. See
Build Cache for worker limits. after without
anchors, a name that is not a configured plugin, and a cycle all fail the
build.
The anchors are part of what a plugin's cached output depends on, so a new anchor on any page reruns the plugins that receive anchors.
When something goes wrong #
All of these fail the build:
- A plugin exits non-zero;
- It prints something that is not a valid response;
- It misses or repeats a block;
- It answers a block with
error.
Block errors and malformed fences are collected across the whole site and reported together, each against its source line:
2 plugin blocks failed:
kernel.product/2--driver-api.topic/1--core.md:14: kernel-doc: drivers/base/nope.c does not exist
kernel.product/2--driver-api.topic/3--bus.md:40: '{kernldoc}' fence names no configured plugin (configured: kernel-doc)
Generated content is ordinary content #
Expansion happens when the site loads, before anything reads a page. The markdown a plugin returns then behaves exactly as if it had been typed:
- Its headings and raw HTML
ids are anchors that links can target, and its own~links are checked during every build; - It counts toward reading time, unless the page's frontmatter sets
reading_minutes; - It is indexed for search and appears in
/printbundles; .linkaliases of the page carry it too.
That includes the markdown mirrors: a mirror shows the expanded content, not the fence. Readers of the mirror, people and machines alike, get the documentation rather than an instruction to go and generate it.
Expanded output is not expanded again. A {name} fence inside a plugin's
output stays a plain code block.
To keep the output separate from the text around it, Trail sets it off with blank lines. Inside a blockquote or a list item, every output line gets the container's prefix.
Rebuilds and caching #
Trail keeps each plugin's last successful output. It reuses that output as long as all of these are unchanged:
- The plugin's blocks: arguments, options, bodies, and the pages they are on. A line-number change reruns a plugin that emitted diagnostics.
- Everything in its
depends_on. Files are compared by content, and directories by the names of the files beneath them, skipping names that start with a dot (such as editors' swap files). The resolved executable also counts, including a bare command found onPATH. - For a plugin with
anchors = true, the anchors it receives.
Under trail serve, a dependency outside
the site root is watched as well, so editing a source file the plugin reads
rebuilds the site. A change reruns the whole plugin, not the affected blocks,
because the plugin can cross-reference across all of them.
The cache persists between processes in .trail-cache/. Use --no-cache
when inputs such as network state or time affect a plugin. See
Build Cache for invalidation and worker limits.
Checking Style
Trail / Writing
trail lint reads a site's sources and reports each breach of its writing
rules, with the file, line, and column. Every rule is off until the site turns
it on, and every dictionary and word list is the site's own, so Trail holds no
house style of its own.
The lint is a separate command. A build never runs it, so a site that doesn't use it is unaffected.
Findings and totals go to stderr:
trail: guide.product/1--basics.topic/100--intro.md:12:41: "e.g.": use "for example" [spelling]
trail: warning: guide.product/1--basics.topic/100--intro.md:30:18: add a serial comma before the last item [serial-comma]
trail: 1 error, 1 warning
The exit status is 1 if any breach is an error, and 0 otherwise. The
command-line reference has the details.
Complete the task #
-
Choose the writing rules, dictionaries, and banned words for the site.
-
Add the
[lint]configuration shown below to its roottrail.toml. -
Run
trail lint <root>and read findings on stderr. -
Correct the sources or add a justified, narrowly scoped suppression.
-
Run the check again. An exit status of 0 means no findings classified as errors remain.
Turning rules on #
Rules are configured in a [lint] table in the root trail.toml, below every
plain key:
[]
= ["spelling", "em-dash", "heading-levels", "line-length"]
= 78
= ["Peios", "Registry Editor", "netd"]
[]
= ["spelling/en_US.dic", "spelling/project-words.txt"]
= ["spelling/banned-words.txt"]
The field and rule reference is in trail-lint(5).
A malformed [lint] table fails trail build too, so a typo can't hide until
someone runs the lint.
Spelling #
The spelling rule checks prose against the files in [lint.spelling].
Trail doesn't include a dictionary, so the site chooses its language and
supplies the files. Paths are relative to the site root, and a build accepts
them there.
dictionaries lists the words prose can use. A file ending in .dic is a
Hunspell dictionary, read with the .aff file beside it, so one entry covers
a word's other forms: en_US.dic accepts "recognized" as well as
"recognize".
Any other file is a word list with one word on each line, for the names and
terms a general dictionary lacks. A lowercase word in a list is accepted
capitalized too. Lines starting with # are comments.
The rule reports a word that no dictionary, word list, or proper_nouns entry
accepts, with a suggested correction where the dictionary has one:
trail: guide.product/1--basics.topic/100--intro.md:4:9: "kernle": not in the dictionary (did you mean "kernel"?) [spelling]
It leaves alone words that hold a digit or an underscore, which are identifiers, and words written in capitals, which are acronyms ("KACS", "SIDs"). A hyphenated compound passes when each of its parts does.
banned-words lists words and phrases prose must not use, one entry on each
line:
# What to write instead:
e.g. -> for example
utilize*, leverage* -> use
# Why, when the replacement isn't one phrase:
simply, just, of course: don't condescend; cut it
# Banned with no advice:
whilst
Entries match whole words, and a phrase matches across a line break. A
trailing * matches any ending, so utilize* finds "utilizes". An entry with
a capital letter matches exactly. In a lowercase entry, each word matches in
lowercase or with only its first letter capitalized, as in a sentence or a
title: logging in finds "Logging In", but may doesn't find the
specification keyword "MAY". A banned word is reported with its own message,
not as a dictionary miss.
Without dictionaries, the rule checks only banned words.
The field and rule reference is in trail-lint(5).
What counts as prose #
The lint reads sources as written, without building them, so nothing a build generates is checked. Prose is the text a reader sees, so these are never checked as words:
- Code spans and code blocks;
- Raw HTML;
- Link destinations and URLs;
- Citation anchors such as
[*name]; - Frontmatter keys.
An article's frontmatter title and description, and every trail.toml and
link file's title and description, are prose. The root trail.toml isn't
checked.
The built-in rules #
Each rule's name is what turns it on, appears in its reports, and suppresses it.
The field and rule reference is in trail-lint(5).
Some rules are heuristics. They aim never to report what isn't a breach, and so they miss some that are.
title-caseandheading-caseleave alone any word inproper_nouns, and any word whose casing is its own: an acronym ("GXWI", "SIDs"), or a name with a capital or digit inside it ("IPv6"). A word after a colon starts a subtitle and can be capitalized. A lowercase name such as "netd" is fine at the start of a title or heading once it is inproper_nouns.line-lengthexempts tables, code blocks, raw HTML, frontmatter, and link reference definitions. A line is also exempt when it fits once its link destinations and URLs are taken out.hex-caselooks inside code spans, unlike every other rule, because a hexadecimal value in prose is usually written as code:0x1F. Code blocks follow the code's own style and are not checked.serial-commacounts a comma-separated run as a list only when every item but the first is at most three words. It also skips a run that starts with an introductory clause or phrase ("If the key exists, read it and write it"), contrasts ("x, notyorz"), gives examples ("such as A or B"), or quotes. A missed list is better than a wrong report, so it's a warning.
Suppressing a rule #
When a page breaks a rule on purpose, such as a style guide quoting the words it bans, suppress the rule rather than turning it off for the whole site.
For one line, put a comment on the line before it:
- For a stretch of a page, put comments around it:
Name one or more rules, or none for every rule. A comment can sit in a
blockquote (> <!-- … -->) or be indented into a list item.
Put the comments between blocks, not inside a paragraph. A comment line ends the paragraph it interrupts, which changes the page. The comments are invisible on the page, but the page's Markdown mirror shows them, because mirrors show the source as written.
For a whole page or a whole book, name its path in [[lint.ignore]]:
[[]]
= "guide.product/3--conventions.book"
= ["hex-case"]
The path is relative to the site root, and covers a file or everything under a
directory. With no rules, every rule is ignored there.
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 #
-
Change to the directory containing
trail.toml. -
Build with description checks:
-
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 #
-
Start the development server from the source directory:
-
Open the address printed by the server. It defaults to
http://127.0.0.1:8724. -
Edit and save an article. Check that Trail reports a rebuild and the browser reloads the page.
-
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:
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.
= "Peios Learn"
= "Documentation for everything Peios"
= "https://learn.peios.org"
= "#3b82f6"
= "Concepts, guides, and reference for the Peios operating system and every project around it — from the kernel to the toolchain that builds it."
= ["peios", "pekit", "provium", "universal-directory", "trail"]
= "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 #
-
Open the existing site root's
trail.toml, or create it with the required values shown below. -
Set the presentation and publishing values needed for the site.
trail.toml(5)describes accepted keys and defaults. -
Run
trail build --strictfrom that directory and resolve configuration errors. -
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 #
= "https://learn.peios.org"
Optional, and worth setting before you deploy. Without it:
- no
sitemap.xmlis written, because sitemaps require absolute URLs, androbots.txtgets noSitemap:line; - canonical URLs stay root-relative rather than absolute;
og:urlis omitted, since a relative one is meaningless to the crawlers reading it;/printbundles 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.
Featured products #
= ["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 #
[[]]
= "Specs"
= "~specifications/pgss"
[[]]
= "Source"
= "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.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 #
= "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"
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.
= ["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.txtreplaces the generated one — useful, and a foot-gun if you nameassets. - 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.
Theming #
Four keys control color:
= "#3b82f6"
= "#7aa8ff" # optional; derived from accent if absent
= "custom.css" # optional
= 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.mdURL, 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/h3headings 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:
- Every HTML page also advertises its mirror in the head:
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.
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:
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 #
| Item | Meaning |
|---|---|
| Every link between pages | breadcrumbs, sidebars, cards, the pager, ~ references in prose |
§ section citations and inline references | Links stay inside the copy |
| Images that live in the tree | the ones trail publishes for you |
| Assets | the stylesheet, the search script, mermaid, your custom.css, the favicon |
| The search index | so 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 entries | copied into the copy as well as the site |
And what does not:
| Item | Meaning |
|---|---|
<link rel="canonical"> | names the real page, so the copy never competes with it |
| URLs you wrote out in full | https://…, and a leading-slash path you typed yourself — trail emits those exactly as written rather than second-guessing them |
edit_url | it points at your repository, not at the site |
robots.txt and sitemap.xml | see 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 #
-
Open the existing site root's
trail.tomland choose its accent settings. -
Use the settings described below; add custom CSS only for changes the built-in settings do not cover.
-
Run
trail build --strictfrom the site root. -
Preview the site in light, dark, and system modes, checking text contrast and image variants.
The three color settings #
= "#3b82f6" # the site's colour
= "#7aa8ff" # optional; derived from accent if absent
= 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:
| State | Meaning |
|---|---|
| System | Follow the operating system's preference. The default. |
| Light | Pinned light, whatever the system says. |
| Dark | Pinned 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.
The tokens #
Everything resolves through CSS custom properties, so overriding a token restyles every place it is used.
| Token | Meaning |
|---|---|
--bg | Page background. |
--surface | Cards, menus, the sidebar — translucent over the background. |
--text | Body text. |
--text-muted | Secondary text: crumbs, meta lines, captions. |
--border, --border-strong | Hairlines and emphasized edges. |
--accent | The site accent, as resolved for the current theme. |
--pc | The product color in scope. Falls back to --accent. |
--glow, --glow-mix | The accent glow behind heroes. |
--headline | The gradient headings are painted with. |
--tile-mix, --tile-fg-mix | How strongly monogram tiles take their product color. |
--card-shadow | Card elevation. |
--menu-bg | The products dropdown, which must be opaque. |
--code-comment, --code-keyword, --code-string, --code-constant, --code-function, --code-type | The 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"
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:
}
}
{
}
}
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.
| Command | Meaning |
|---|---|
/theme | Cycles system → light → dark, exactly as the header button does. |
/theme <name> | Goes straight to system, light, or dark. |
/cachebust, /cb | Opens 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.
Directory and File Names
Trail / Reference
Trail uses directory names to derive navigation and URLs. A source name
contains an order, a slug, and sometimes a kind suffix. trail-source(5)
is the authoritative naming and containment reference.
Read a source name #
In 200--getting-started.topic, 200 controls sibling order,
getting-started supplies the URL slug, and .topic selects the grouping
kind. Root collections use a slug and .product or .antho, without an
order.
Choose topics for independently readable pages and books for an ordered document with section numbers. Shelves group navigation without adding a URL segment. See Anatomy of a Site for a complete example tree.
Keep names stable #
Renaming a slug changes URLs and references. Order changes usually affect
navigation only; in books they also affect published section numbers.
Run trail build --strict after structural changes to find broken links.
Use link aliases when the same page belongs in several navigation locations. An alias does not duplicate the source article.
Reserved names #
Trail publishes generated pages and asset directories alongside authored
content. Some slugs are reserved to prevent collisions. trail-source(5)
lists them and the allowed files at each level of a tree.
trail.toml Reference
Trail / Reference
Each trail.toml configures the source directory that contains it. The
root file defines site-wide presentation, merged trees, attachments, plugins,
and writing rules. Grouping files describe their own navigation unit.
trail.toml(5) is the authoritative key and validation reference.
Configure the site root #
Start with Configuring the Site. Set a public URL when you publish the site so canonical links and discovery files can use absolute addresses. Keep deployment-specific values in the root configuration rather than repeating them in articles.
Configure a grouping #
Products, anthologies, and books carry their own presentation metadata.
Topics, chapters, and shelves can override their derived titles. The
accepted keys differ by kind; trail.toml(5) lists each set.
Derived titles #
When a grouping has no explicit title, Trail converts its slug to title case. The first and last words are capitalized; internal articles, conjunctions, and short prepositions generally stay lowercase. Use an explicit title for a proper name or an identifier whose casing cannot be derived from the slug.
Reuse terminology #
An inline reference associates a phrase with a page or grouping. The phrase then links to that destination when used in prose. See Inline References for examples.
Add generated content #
A configured plugin expands named Markdown fences. Its command runs with
the privileges of the build process, so review plugin configuration before
building a source tree. trail-plugin(5) documents the process interface.
Writing Plugin Blocks explains how to use it.
Check writing #
The optional [lint] table enables writing checks. trail-lint(5) documents
the rules and configuration. Checking Style
walks through running the check and interpreting findings.
Frontmatter Reference
Trail / Reference
Frontmatter gives an article its title and metadata before its Markdown
body. trail-frontmatter(5) is the authoritative field reference, including
types, defaults, validation, and differences between topic and book pages.
Write useful metadata #
A title helps readers choose a page. A description explains its scope in search results and Markdown mirrors. A topic page's type distinguishes a concept, a how-to, or a reference; books already have a document structure and do not accept that field.
Writing Articles and Frontmatter
shows a complete example and explains how metadata affects the reading
experience. trail build --strict checks that descriptions are present.
Connect related material #
Related-page references guide a reader to a useful next topic. Inline references make a recognizable phrase link to its definition. These serve different purposes: use related pages for a reading path and inline references for terminology.
See Inline References for matching and Writing Links and References for explicit links.
Command-line Reference
Trail / Reference
Trail provides commands for building, serving, and checking documentation.
trail(1) is the authoritative command reference, including every option,
exit status, environment input, and output path. Use trail --help for a
summary or trail help build for one command.
Building a site #
Run trail build --strict from the directory containing trail.toml to
check descriptions and build the site. The build validates links even
without --strict. Read Building and
Serving
for a worked procedure and output ownership rules.
Previewing changes #
Run trail serve to preview the site while editing. It rebuilds after
source changes and reloads connected browsers. Failed builds report a
warning while the server stays running. Output can contain partial writes
from a failed build; it is not an atomic snapshot of the last success.
Checking writing #
Run trail lint separately from a build. Findings and totals go to stderr.
Each finding names its source path, line, column, and rule. A warning uses
trail: warning:; an error uses trail:. The exit status is 1 if a rule
reports an error, and 0 if there are only warnings or no findings.
Checking Style explains configuration.
Exit status and streams #
Help, version, and successful commands exit with status 0. Operational failures exit with status 1. Usage errors exit with status 2. Running Trail without arguments prints help to stderr and exits with status 2. Build and server progress use stdout. Errors, warnings, and lint findings use stderr. Plugin diagnostics retain the plugin's own formatting.
Installing #
Build Trail from its source directory:
pekit prints where the result is, under pekit-out/. Run tools/install
to install the binary and manuals under $HOME/.local. See
Building Trail for prerequisites,
checks, and a custom installation prefix. Read a manual directly with
man ./man/trail.1 from the source directory.