# Maintain these docs

> How these docs are built from Markdown, how to add or change a page, the checks that keep them honest, and the rule that keeps them in step with the app.

Source: https://crawl-docs.pdhq.win/advanced/maintain-these-docs/
Last updated: 2026-12-04

The docs are the Next.js app `apps/docs`. Its pages are Markdown files in `apps/docs/content`. A build turns them into a static site, a Markdown copy of every page, `llms.txt`, `llms-full.txt`, a search index, a sitemap and `robots.txt`.

## The rule

> **A change to what the app does or shows is not finished until the page that describes it is changed in the same pull request.**

The same rule is written in the repository's `CLAUDE.md`, so an AI assistant working in the repository follows it too.

A page that is wrong is worse than a missing page. When you change a screen, a setting, a route, a column or a message, search the pages for its name and fix what you find:

```bash
grep -rn "the thing you changed" apps/docs/content
```

Say in the pull request which pages changed. If a feature has never been tried on the real thing, say so on the page with a `[!NOT-TESTED]` block instead of leaving it out.

## Add a page

1. Create `apps/docs/content/<section>/<name>.md`, where `<section>` is `guide` or `advanced`. The file name is the address.
2. Start it with front matter:

```text
---
title: A short name, 70 characters at most
description: One sentence, 40 to 200 characters, that says what the page tells. Search and AI indexes show it.
updated: 2026-12-02
---
```

3. Add its slug (`guide/<name>`) to a group in `apps/docs/content/nav.json`. The order in the file is the order in the sidebar and the order of the previous and next links.
4. Write the body. Do not write a `#` heading: the title comes from the front matter. Use `##` and `###`, and do not skip a level.
5. Run `yarn workspace @social-crawl/docs check`.

## Write the way the docs are written

- **One topic per page.** If a page needs two titles, make two pages.
- **Say what you should see** after each step in the Guide.
- **Describe every screen in words** with a `> [!SCREEN]` block of at least 40 characters. The build refuses a shorter one.
- **A picture needs alt text** that says what it shows. The build refuses an empty one.
- **Link with root paths**: `[Install the server](https://crawl-docs.pdhq.win/guide/install-the-server.md)`. A link to a heading uses its address: the heading text in lower case with dashes (`#step-2-make-your-password-s-hash`). The build checks that the page and the heading exist.
- **Check it against the code.** Every command, setting name, button label and message on a page must be copied from the code or the real app, not remembered.
- **Plain words.** The Guide is for someone who has never seen the code. Keep the code details in Advanced.
- Callouts: `[!NOTE]`, `[!TIP]`, `[!IMPORTANT]`, `[!WARNING]`, `[!CAUTION]`, `[!NOT-TESTED]` and `[!SCREEN]`. Each draws an icon and a word, so the kind never depends on colour alone.

## What the build checks

`yarn workspace @social-crawl/docs build` (and `check`) stops with a list of problems when:

- a page has no title, a title over 70 characters, a missing or odd-length description, or a bad `updated` date;
- a link goes to a page or a heading that does not exist;
- a picture has no alt text, or a `[!SCREEN]` block is too short;
- a heading skips a level, or the body has its own `#` heading;
- a callout kind is unknown, or the text has `TODO`, `TBD` or placeholder text;
- a page file is not listed in `nav.json`, or is listed twice.

## The generated page

[API routes and scopes](https://crawl-docs.pdhq.win/advanced/api-routes.md) is made from the API's controllers. Do not edit it by hand. After you add, change or remove a route run:

```bash
yarn workspace @social-crawl/docs routes
```

and commit the result.

## Build and preview

```bash
yarn workspace @social-crawl/docs dev       # live, at http://localhost:3000
yarn workspace @social-crawl/docs build     # the static site in apps/docs/out
yarn workspace @social-crawl/docs test      # the content and search tests
```

Set `DOCS_SITE_URL` to the real address of the docs before a production build, so `llms.txt`, the sitemap and the canonical addresses are right. See [Deploy and operate](https://crawl-docs.pdhq.win/advanced/deploy-and-operate.md) for the container.

## How the pages draw

The Markdown is rendered with `react-markdown` and GitHub-flavoured tables. Callouts, code blocks with a copy button, headings with anchors and the "On this page" rail with its scroll-following line are components in `apps/docs/src/components`. The rail is the scroll-spy table of contents from the `table-of-contents` repository, copied in. Colours come from the same tokens as the web app, so the docs match it.
