Add a page #
Prompt:
Add a page to the docs about the export command.
Also works: "Document the new setting." "Move the FAQ under Troubleshooting." "Hide the internal notes page from the site."
What your tool does #
- Reads the source folder's layout to choose the folder, the file name, and the next
order. - Writes the file with a front-matter block:
titlealways,descriptionin one sentence, and the other keys where the default is wrong. - Links the new page from the pages that already mention the subject.
- On a rename or a move, keeps the old slug in
redirects_fromso that old links still reach the page. - Runs
tzdocs check --source docsand corrects what it reports, then runs the build and reports the success line. - Asks nothing, because every step writes source files in your project. What happens without asking lists what the build writes.
What you need #
- Which section the new page belongs in, or that you want a new section created for it.
Before your AI starts #
This section is for your AI coding tool: what it checks and gathers before it begins. You don't need to do these steps yourself.
- A corpus with a home page at its root,
index.md, and the tool installed (Getting started).
Steps #
1. Choose the folder and the file name #
The file's path sets the page's slug, its URL path within the site: guides/first_guide.md becomes /guides/first-guide. The folder sets the section where it contains an index.md. A slug key overrides the derived slug, and the check reports one that puts the page in another folder. Follow the slug rules, which also list the reserved names and the paths that collide.
2. Write the front matter #
Start the file with a front-matter block between two --- lines. title is the only required key.
---
title: Export command
description: Export a corpus's pages to another format.
---
Add description in one sentence, and the other keys only where their default is wrong. Front matter lists the seven keys with their defaults and the value forms the parser accepts.
3. Set the order #
Give the page an order to place it among its siblings. On a folder's index.md, order places the whole section. A new section is a folder with an index.md that contains only front matter, its title and its order. A page without an order comes after the pages that have one. Order gives the full sort rules.
4. Hide the page, where it is not for readers #
Set visibility to any value other than public to hide the page. The build then leaves it out of the HTML, the navigation, the index, the manifest, the Markdown copies, and the whole text. --include-hidden builds it into all of them.
Visibility controls what the build writes and protects nothing. Where hidden pages are built, the site that serves the files controls who can read the HTML and the machine files. A hidden page's front matter is still parsed, so an error in it fails the default check or build.
5. Link the page #
Link to the page by its tree-relative path, such as /guides/export/, or by a path relative to the linking page, such as export.md. To link a heading, add its anchor as a fragment, such as #options, and read the anchor from the manifest. Links gives the link forms and the anchor rule.
6. Add an image or a file #
Put the image or the file in the source folder, beside the page or in a folder of its own, and refer to it by its path:

Download [the sample export](../files/sample.zip).
The build copies every file whose name does not end in .md to the same path in the output. It writes each reference as an address relative to the built page, so it works under any base path. A path that starts with / is read from the source folder. A file in a folder whose name begins with a dot is not copied. Images and other files gives the rules.
A reference to a file that is not there stops the build, and the check names the page and the path.
7. Rename or move a page #
Move the file, or change its slug, and add the old slug to redirects_from in the same change. The build writes a redirect stub at the old slug, so old links to the page keep working. Redirect stubs describes the stub. A link to a slug that no page or redirect has stops the build, and the check reports it.
8. Check and build #
Run tzdocs check --source docs, correct what it reports, and run the build. Check a corpus covers the loop.
Expected result #
The check prints its one success line and exits with code 0. The build then places the page in:
- the navigation, at its order;
- the index, under its section's heading;
- the manifest, with its headings and anchors;
- the whole text;
- a Markdown copy beside its HTML, at
<slug>/index.md.
At a renamed page's old address, the build writes a stub that redirects to the new address.
Refusals #
A refusal stops the build before it writes anything, and the check reports it first. An advisory finding lets the build proceed. Refusals and findings gives every message's exact text.
| Finding | Cause | Remedy |
|---|---|---|
two files resolve to one slug |
Two files derive or declare the same slug, guides/first_guide.md and guides/first-guide.md for example, since a slug turns underscores into hyphens. |
Rename one file or change its slug. |
redirects_from <slug> on <file> collides with the live slug of <file> |
An entry in redirects_from is a page's current slug. |
Remove the entry, or rename the page it collides with. |
unsafe slug path, unsafe redirect path |
A slug, declared or derived from the file name, or a redirect breaks a slug rule. | Write a safe tree-relative slug, or rename the file. |
duplicate redirect |
Two pages list the same old slug. | Keep the entry on the page the old address should reach. |
output path collision |
Two pages differ only in letter case, a page's path is another page's folder, or a slug or a copied file uses the name of a reserved root file or a page's path. | Rename one of the two, or move the page or the file off the reserved name. |
unsafe file path |
A copied file's path breaks a slug rule. | Rename the file. |
missing file |
An image or a file link names a file the source folder does not have, or climbs above it. | Add the file, or correct the path. |
broken internal link, to a page |
A link points to a slug no page or redirect has. | Correct the target, or add the redirect. |
reserved section title |
A top-level section is titled Start here or Optional in any letter case. The index uses those two headings. |
Retitle the section's index page. |
section index with a body |
A section's index.md has body text while its folder contains other pages. |
Move the text to a page of the section. |
malformed front matter |
The front matter breaks a front-matter rule: a bad key, a bad value, an unclosed block, or no title. | Correct the named file, at the line the finding quotes where it quotes one. |
broken internal link, to a heading (advisory) |
A fragment matches no heading anchor, or a fragment's percent encoding is malformed. | Correct the fragment, or add the heading it points to. |
slug diverges from its folder path (advisory) |
A declared slug puts the page in a folder other than its source folder. | Move the file, or drop the declared slug. |
section names no section of the corpus (advisory) |
A declared section word is not the word of any top-level section. | Write a top-level section's word, or drop the key. |
Related #
- Page source lists the slug, front-matter, order, and link rules this guide applies.
- Highlight a code block gives the fence line for the code samples on the page.
- Check a corpus runs the check and corrects the findings.
- Output describes where the build writes the page in the tree and in the machine files.
- Glossary defines slug, route, section, and order.