Page source #
On this page
This page lists the rules a Markdown source page follows: its slug, its front matter, its order, its links, the images and other files beside it, its code blocks, its callouts, and its diagrams. Add a page is the guide that shows how to apply them.
Start with the front matter at the top of each Markdown page: only title is required, and every other key has a default (Front matter). The file path sets the page's slug, its URL path within the site, unless a slug key in the front matter overrides it (Slugs).
Slugs #
A page's slug is its URL path within the site. By default the slug comes from the file path:
guides/first_guide.mdbecomes/guides/first-guide: underscores become hyphens, and.mdis removed.guides/index.mdbecomes/guides.- The root
index.mdbecomes/.
A file name therefore sets the slug, and a folder containing an index.md sets the section. A slug key in the front matter takes precedence over the derived slug. The check reports a declared slug that puts the page in a different folder from its source file, because the navigation follows the source folders.
Slug rules #
A slug is /, or a path that starts with / and has no empty segment. A slug must not contain:
- repeated slashes, or a trailing slash other than
/itself; - a
.or..segment; - a backslash, a query string, or a fragment;
- a control character, or any of
<,>,:,",|,?,*.
A segment must also not end in a dot or a space. It must not be a reserved device name in any letter case, with or without an extension: CON, NUL, PRN, AUX, COM1 through COM9, or LPT1 through LPT9.
The tool refuses a malformed percent encoding. It decodes each segment once for these rules, so an encoded slash or backslash is refused too. The tool keeps the slug as written and changes nothing in it.
Path collisions #
The tool compares generated paths in lower case on every platform, so /Guide and /guide collide. A file cannot also be a folder: /guide/index.html collides with the HTML written for /guide.
The root names docs.css, site.css, docs.json, llms.txt, llms-full.txt, sitemap.xml, 404.html, and mermaid.min.js are reserved for the build's own files. Each is reserved even when the build does not write it, site.css when the build is given no stylesheet for example.
A file beside the pages follows the same rules. Its path must be a safe slug, and it collides with a page, a redirect, or a reserved name as a page does. A source file guide/index.html, for example, collides with the HTML written for a page at /guide.
Front matter #
Front matter is the metadata block between two --- lines at the start of the file. The parser accepts eight keys, and only title is required.
---
title: First guide
description: What the guide lets the reader do, in one sentence.
slug: /guides/first
order: 2
visibility: public
redirects_from: [/old/first-guide]
---
| Key | Required | Default | Notes |
|---|---|---|---|
title |
yes | — | The page's title, in the navigation, the page head, the index, and the manifest. |
description |
no | empty | One sentence, in the page head, the index line, and the manifest row. |
slug |
no | derived from the file path | Tree-relative, with a leading slash. A declared slug takes precedence over the derived one. |
order |
no | by slug among siblings | An unquoted decimal integer from -9007199254740991 through 9007199254740991. Order gives the sort rules. |
visibility |
no | public |
Any other value leaves the page out of the build, the navigation, and every machine file, unless the build passes --include-hidden. |
redirects_from |
no | empty | A one-line inline list of old slugs. The build writes a redirect stub for each. |
section |
no | the first slug segment, or home for the home page |
The section word the manifest records for the page, which a page kept at the root can set to its section's word; the check reports a word that names no top-level section. |
toc_max_heading_level |
no | 3 |
The deepest heading level the page's On this page list shows: 2 lists the second-level headings alone, 3 adds the third-level headings. Any other value is refused. |
The block #
- The block opens on the first line with
---and closes on a later line that contains exactly---. - Blank lines inside the block are allowed.
- Every other line is an unindented
key: valueentry.
The build refuses an unknown key, a duplicate key, a multiline value, or a structured value. The tool parses every file's front matter before it applies visibility, so malformed front matter in a hidden page also fails the default check or build.
Values #
| Form | Rule |
|---|---|
| Plain | Trimmed. A # inside it stays literal text. |
| Single-quoted | An apostrophe inside it is doubled, as in title: 'It''s a guide'. |
| Double-quoted | JSON string escapes apply. |
A quoted value must close, with nothing but whitespace after it. A value that starts with [, {, |, >, &, *, or ! must be quoted to be read as text. So must a value that starts with - or ? followed by whitespace. Write title: "{name: Example}", not the bare braces. The parser accepts only these forms and is not a general YAML parser.
The redirects_from list #
redirects_from is a one-line list in brackets. Commas outside quotes separate the entries, and a comma inside quotes stays part of its value. [] is valid, and an empty entry is refused. Each entry follows the slug rules.
Order #
order is read at two scopes:
- On a folder's
index.md, it places the section among its parent's entries. - On any other page, it places the page among its siblings.
Entries sort by these rules:
- Entries with an order come first, by order.
- Entries with the same order sort by slug.
- Entries without an order come after, by slug.
Slugs sort in character-code order, so an uppercase letter comes before a lowercase one. The navigation order is therefore the same on every build.
Sections #
A subfolder containing an index.md is a section. The corpus root is different: its index.md is the home page and may contain body text alongside other pages. If a section folder also contains other pages or sections, the section is a group in the navigation that the reader opens and closes, and its title is not a link. Its index.md contains only front matter: the title gives the section its name, and the order places it. The build writes no page for it, and it refuses an index that has any text after its front matter.
If the folder contains only its index.md, that file is a page like any other, at the folder's slug, and the navigation links it.
A folder without an index.md is not a section. Its pages appear among the entries of the nearest folder above it that is a section, or of the root, each placed by its own order. Their slugs still come from their paths, so the folder groups their addresses without adding a group to the navigation.
Links #
The check and the build resolve internal links with the same rules. Write a link in one of two forms:
- a tree-relative path, such as
/reference/output/; - a path relative to the source page's folder, such as
code_blocks.mdor../reference/output.md.
For a relative path, the tool removes .md, replaces underscores with hyphens, and treats index as its folder. If a page declares a slug that differs from its derived path, link to the declared slug.
The build rewrites a link to a page or a redirect as a relative HTML link. Output says how those links open. An external URL and a link to an anchor alone keep their spelling. A query string does not affect the lookup. A link that matches no page or redirect stops the build, and the check reports it.
A fragment such as #details must match a heading anchor on the destination page. This applies to a link to the current page and to a link through a redirect. A fragment that matches no heading is an advisory finding: the check reports it, and the build proceeds. The check does not read links or images written in raw HTML, or a custom id in raw HTML, and it does not fetch external URLs.
Images and other files #
Every file in the source folder whose name does not end in .md is copied to the same path in the output, byte for byte: an image, a download, or any other file. A file in a folder whose name begins with a dot, or whose own name begins with one, is not copied, so .DS_Store and .git never ship. A file that only hidden pages reference is left out with them, unless the build passes --include-hidden. A file no page references, such as one linked only from raw HTML, is still copied.
A page refers to a file in two ways:
- an image, such as
; - a link whose target ends in an extension other than
.md, such as[the sample](../files/sample.zip).
The tool resolves the path against the source page's folder, or against the source folder for a path that starts with /, as it does for a link to a page. It keeps the file's name as written: underscores stay. The build then writes the copied file's address relative to the built page. A page at guides/add_a_page.md is built at guides/add-a-page/index.html, one folder deeper, so its diagram.png becomes ../../guides/diagram.png.
A query string or a fragment after the path is kept. An external URL, a data: address, and an anchor keep their spelling, and an image or a link written in raw HTML is not rewritten.
A reference to a file the source folder does not have stops the build, and the check reports it. The Markdown copy beside each page keeps the source as written, except that its links and images to pages and files are written as addresses under the base path.
Heading anchors #
The build gives each heading an id, its anchor, by these steps:
- Remove the HTML tags from the rendered heading. Decode decimal (
') or hexadecimal (') numeric references with values from 1 through 0x10FFFF, and&,<,>,", and', once. Leave other references as written. - Write it in lower case.
- Replace every run of characters other than the ASCII letters a to z and the digits 0 to 9 with one hyphen.
- Remove leading and trailing hyphens.
An anchor left empty becomes section, and a duplicate gets the suffix -2, -3, and so on. For example, What's new has the anchor what-s-new. The manifest lists each page's anchors.
Markdown-only sections #
Wrap text intended for AI readers in these markers to keep it in the Markdown outputs and leave it out of the HTML page:
<!-- tzdoc:markdown-only -->
## Instructions for AI tools
Read the complete example before calling the tool.
<!-- /tzdoc:markdown-only -->
Write each marker on its own line at the top level, outside a list, quote, code block, or raw HTML block. Use a blank line around each marker. Sections can contain headings, prose, lists, and code blocks. Multiple sections are allowed; nesting is not. The check and build reject an unmatched closing marker, an unclosed section, or a nested section. Spell each marker exactly as shown: a comment spelled any other way is an ordinary comment, and the check does not report it.
The page's index.md keeps the entire source, including the markers. Its entry in llms-full.txt keeps it too, unless the build excludes that page from the full text. This is a presentation option: the text remains publicly readable wherever those files are served.
The HTML page and the manifest's heading list omit the marked content. If the first top-level # heading is marked, its generated “View this page as Markdown” link is omitted too. Fenced code blocks remain in the manifest's code-block inventory, but a marked Mermaid block does not load the diagram script. Reference-style link definitions still apply to the whole source.
Links inside marked sections are checked for missing pages and files. HTML heading-anchor checks apply only to visible links; a visible link to an omitted heading is reported as broken. Use a page's Markdown copy when directing AI readers to its marked content.
Code blocks #
The renderer used on this website accepts the copy= key described below. Leave it out when using npm 0.13.0. See Website and npm versions.
A fenced block's opening line carries its info string. Put the language word first if you use one. A title, copy key, line set or showLineNumbers can open the info string on its own. Use the optional keys in any order after the language word.
| Key | Effect |
|---|---|
title="<text>" |
Captions the block. Single quotes work too. |
copy="<words>" |
Adds the words after “Copy” in the button's accessible name. Single quotes work too. |
{2,5-6} |
Emphasizes the lines listed, counted from 1. |
showLineNumbers |
Numbers the block's lines, counted from 1, in a gutter at the left. |
The numbers are drawn by the stylesheet and are not part of the block's text, so the copy control copies the block without them. Any other key is a check finding. Parsing stops at it, and the keys before it still apply. Highlight a code block is the guide.
Callouts #
A block quote whose first line is exactly one of five markers renders as a callout, as on GitHub:
| Marker | Title |
|---|---|
[!NOTE] |
Note |
[!TIP] |
Tip |
[!IMPORTANT] |
Important |
[!WARNING] |
Warning |
[!CAUTION] |
Caution |
> [!WARNING]
> The build replaces the whole output folder.
The marker is read in any letter case, and spaces after it are ignored. The rest of the quote becomes the callout's body, which can hold paragraphs, lists, and code blocks. A first line with text after the marker, such as [!NOTE] Read this, is no marker, so the quote stays a block quote. A bracketed word that is not one of the five, such as [!WARN], stays a block quote too, and the check reports it.
Diagrams #
A fenced block whose language word is mermaid holds a diagram in Mermaid's text syntax:
```mermaid
graph TD
A[Write] --> B[Build]
```
The built page draws it in the browser if Mermaid is installed for the build. The file mermaid/dist/mermaid.min.js must resolve from the folder the command runs in, as npm install mermaid in that folder provides. Otherwise, or with --diagrams-as-code, the block renders as a code block in the language mermaid. Use the mermaid language word by itself. A title, line set, showLineNumbers or copy= on a diagram is a check finding. Add callouts and diagrams is the guide.
Related #
- Add a page shows how to apply these rules step by step.
- Refusals and findings gives the message for each rule a page breaks.
- Output describes where the build writes each page.