Organizing navigation

How a site's sidebar is built from the ## Topics sections of its pages — children, groups, order, labels, repeated pages and pages left out — and how to use that to give a site a reading order that goes from its landing page down to reference. It is a task article under the viewer; the navigation tree mechanism explains the implementation.

A Topics section

A page lists its children in a section headed exactly ## Topics, normally at its end:

## Topics

### The system

- [Viewer]boxes/viewer/README.md — serves a document.
- [Engineering]boxes/engineering/README.md — how changes reach main.

The rules:

Links anywhere else in a page — paragraphs, other sections, a "where next" list — never change the sidebar. Use them freely to link across the tree.

How the tree grows

The sidebar starts with the site's title, which links to the root page. Under it come the root page's Topics children; under each child, that page's own Topics children, and so on down.

For example, take three pages whose Topics sections list:

README.md          → Guide (guide.md), Reference (reference.md)
guide.md           → Step (step.md), Reference (reference.md)
reference.md       → Fields (fields.md)

The tree is read depth first, in list order, so Reference is first met under Guide — that appearance shows its children — and the root's own listing of it, met later, is a leaf:

flowchart TD
  title["Document title<br/>links to README.md"] --> guide["Guide"]
  title --> ref2["Reference<br/>listed again: not expanded"]
  guide --> step["Step"]
  guide --> ref1["Reference<br/>first appearance: expanded"]
  ref1 --> fields["Fields"]
  click title href "../configuration-reference/README.md#site" "The root page"
  click guide href "#a-topics-section" "A Topics section"
  click ref1 href "../navigation-tree/README.md#building-the-tree-and-stopping-cycles" "How repeats are stopped"
  click ref2 href "../navigation-tree/README.md#building-the-tree-and-stopping-cycles" "How repeats are stopped"

Both Reference entries link to the same page, and both are highlighted while it is shown.

Because the tree is read from the files on every request, editing a Topics list changes the sidebar of every open page as soon as the file is saved.

The navbar

A site can have a bar across the top, beside its sidebar or instead of it. Its title sits on the left — after its logo, when the document file names one with logo — and opens the root page; the navbar field of the document file lists what sits on the right, in order:

kind: site
title: devpage
root: README.md
navbar:
  Docs (book-open): README.md
  Getting started (rocket): getting-started.md
  Examples (layout-grid):
    Site — these docs (book-open): README.md
    Doc — feature catalog (file-text): features/devpage.yml
    Slides — the devpage talk (presentation): talks/devpage/devpage.yml
    Design — the checkout prototype (frame): designs/checkout/checkout.design
  (github): https://github.com/andrei512/devpage

A link to a missing page, an unknown icon name or a logo that names no file is a problem, like any broken link — reported once for the document file, and devpage check follows the navbar's links like any others. The navbar's title replaces the sidebar's: with a navbar, the sidebar starts straight at the tree.

The logo. logo: logo.svg in the document file — an image relative to it, usually a square SVG — shows at 22px before the title, in the navbar or, with no navbar, at the head of the sidebar, and is the browser tab's icon on every page of the site. A doc and a deck take a logo too: before a doc's title in its outline, and as the tab's icon of both.

Sidebar, navbar or both. The sidebar shows unless the site sets sidebar: false; the navbar shows when navbar is set. A site with neither is just its pages, linked by their text.

Structuring a site's reading order

The Topics lists are the site's table of contents, so lay them out the way a reader learns. This repository's documentation skill (.claude/skills/documentation/SKILL.md) describes five layers, each answering a different question:

Layer Question it answers What it holds
1. Landing What is this, and where do I go? A subject's README: what it is in a few paragraphs, one picture of its parts, Topics grouped by what the reader wants.
2. Essentials How should I think about it? One or two articles teaching the mental model with one example walked end to end.
3. Concepts and tasks How do I work with it? Articles around what a reader wants to understand or do, linking down into mechanisms.
4. Mechanisms How does this part work inside, and why? One page per mechanism: design, reasons, failure modes.
5. Reference What exactly is the contract? Schemas, APIs, configuration — complete and exact.

In practice:

The viewer is laid out this way: its Topics run from Getting started down to the configuration reference.