zudo-doc-writing
Doc-writing and navigation-structure guide for this zudo-doc project. Consult BEFORE creating pages, adding categories, designing header navigation, or writing/editing mdx content under src/content/. Covers: reading the AUTHORING.md editorial policy and its four placement questions, when to run a structure review, plan-the-nav-tree-first workflow, tree vs note-tray categories, the recommended 3-level hierarchy (header → sidebar → nested), filesystem navigation as the default, linked versus heading-only category rows, category index pages, sidebar_position discipline, frontmatter schema, no-h1 rule, relative .mdx links, and admonition syntax. Triggered by 'write docs', 'add a page', 'create a page', 'add category', 'structure navigation', 'nav design', 'zudo-doc-writing'.
- License 许可
- MIT
- 所属仓库
- zudolab/zudo-doc
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- zudo-doc-writing
- description
- Doc-writing and navigation-structure guide for this zudo-doc project. Consult BEFORE creating pages, adding categories, designing header navigation, or writing/editing mdx content under src/content/. Covers: reading the AUTHORING.md editorial policy and its four placement questions, when to run a structure review, plan-the-nav-tree-first workflow, tree vs note-tray categories, the recommended 3-level hierarchy (header → sidebar → nested), filesystem navigation as the default, linked versus heading-only category rows, category index pages, sidebar_position discipline, frontmatter schema, no-h1 rule, relative .mdx links, and admonition syntax. Triggered by 'write docs', 'add a page', 'create a page', 'add category', 'structure navigation', 'nav design', 'zudo-doc-writing'.
- user-invocable
- true
03 SKILL.md 正文
zudo-doc Writing & Navigation Guide
IMPORTANT: Follow this guide strictly when creating or editing documentation in this project. AI tools that skip the navigation-planning step produce chaotic, hard-to-navigate doc structures almost every time — this skill exists to prevent exactly that.
The Project Policy Comes First
This project's editorial policy is AUTHORING.md at the project root — the same file README.md, CLAUDE.md, and AGENTS.md point to. It records who the docs are for, what each category contains and excludes, and the project's URL, translation, and generated-content constraints. This skill adds zudo-doc's navigation mechanics on top of it; when the two disagree about a category, the policy wins. If the project moved its policy elsewhere, follow the path its CLAUDE.md names.
- Typo, wording, or formatting fix only → skip everything below except the per-page writing rules.
- Adding a page, a new reader task or topic, or changing a page's role → answer the policy's four questions before writing:
- Who can do what with this content?
- Does an existing page already serve that role? Prefer updating it over creating a near-duplicate.
- Why this category, and is there a competing destination?
- Does this addition change what the category means?
- Answers are clear → place the page and report the placement reason in one line.
- Evidence of a category conflict, duplication, a new independent cluster of reader tasks, or a findability problem → run the structure review described in the policy: write the concrete reader problem first, read the category map plus only the related or competing pages (say what you surveyed — a partial look is not a full audit), and compare adding to an existing page, improving while keeping the structure, a local reorganization, and related links or an index. Keep only options that solve the reader problem, then prefer the smaller change. Keeping the structure is a valid result. Never decide by page count or category balance.
- Recording → only category meaning, important exceptions, and the reason for a reorganization that happened go into the policy, labeled [decision], [fact], or [hypothesis]. Leave TBD fields TBD instead of guessing, and do not reorganize the same category again without new evidence.
- Ask the owners only when important goals conflict and the policy does not resolve it — for example, a published URL that must stay versus the correct category — and present the concrete options with their effects.
Step 0 — Plan the Navigation Tree BEFORE Writing Anything
Never create pages one by one "wherever seems closest." Before writing the first page:
- List every topic the site must cover.
- Draw the full navigation tree (header items → sidebar categories → pages) as a plain-text outline.
- Only then create directories and files matching that tree exactly.
When adding to an existing site, read the current tree under src/content/docs/ first, draw it out, and place the new page where it fits the hierarchy — never skip this step. Separate a logical reclassification from a physical file move: moving a file changes its URL, so check the policy's list of URLs that must stay before moving anything.
Before choosing any navigation configuration, also write down how each destination behaves: which header section owns it (its URL's categoryMatch), what a fresh visit and Restore show in the sidebar, which branches start open, and how far Broaden tree may go. Choose the pattern from that list:
- Header dropdown — collects independent sections in the header. Each keeps its own sidebar; the dropdown creates no sidebar parent.
- Shared sidebar hierarchy — one linked landing page is the real parent of the rows below it.
- Curated editorial tree — lists particular pages and cross-links; a cross-link stays a leaf.
- Umbrella tree — a shared hierarchy whose children are complete native sections; only the section list is authored, so new pages inside a section appear automatically.
When asked to match an existing hierarchy, keep its linked parent rows and every descendant. Do not replace them with a flat hub of peer links because the directories are siblings. items: ["learn", "guides", "components"] in the sidebar config is such a flat hub: each string is a leaf link. scopeRoot only caps Broaden tree and initialPath only selects a view; neither creates a parent. The editorial and umbrella recipes are advanced chrome-bindings recipes — see the Editorial navigation guide under Full Guides below.
The 3-Level Hierarchy
Design for three navigation levels. This is a usability recommendation, not a technical maximum — the sidebar is recursive and renders any depth — but deeper trees are harder to read:
- Header nav — the broadest categories (3–6 items max)
- Sidebar — all pages of the active category (generated from the filesystem)
- Nested sidebar categories — subsections within a sidebar (2–3 levels of nesting max)
Each level narrows scope. Never jump levels — do not put a specific page directly in the header, and do not bury a whole category inside a deep sidebar fold.
File Structure Is the Default Navigation
This is the single most important rule. By default, the directory tree under src/content/docs/ is the navigation, with no separate config to keep in sync. Recommend this default first:
- A directory becomes a sidebar category. Its
index.mdxis the category landing page. - A file becomes a sidebar item.
- Subdirectories become nested collapsible categories.
- The
headerNavsetting maps top-level directories to header items viacategoryMatch.
Consequence: design the filesystem with navigation in mind from the start. When the wanted hierarchy differs from the directories, move the files.
Editorial trees are supported for the case where existing URLs must stay but the sidebar needs different parents, including links to pages in other sections. That is an advanced chrome-bindings recipe (see the Editorial navigation link under Full Guides below); recommend it only when moving files is not an option. An editorial or umbrella tree changes only the paired header and sidebar: breadcrumbs, the previous/next pager, search, the sitemap, and <CategoryNav> keep following the URL tree, so a sidebar change alone does not make them agree.
Category Shapes — Tree or Note Tray
Choose the shape before writing a category's index.mdx:
- Tree (default) — a topic hierarchy that may contain subdirectories. Its
index.mdxis a short intro plus<CategoryNav category="<dir>" />. - Note tray — a top-level, flat sequence such as a journal, course, or notebook. Declare
category_shape: "note-tray"on a visible routedindex.mdx, keep only direct child files, and use<NoteTrayIndex />instead of<CategoryNav>. Order always comes fromsidebar_positionpluscategory_sort_order.note_tray_dated: truerequires adateon every child, including unlisted ones;note_tray_sidebaraccepts"index","year", or"month", and the grouped styles need a dated tray.
A note tray that holds many entries is still a sequence. Do not convert it into a topic tree because of its size; do that only when readers need topic access the sequence cannot give, and record the reason in the policy.
Linked Parents vs Heading-Only Groups
Decide for every group row whether it is a link:
- Linked parent — a real category node backed by a page. An authored
index.mdxgives it intentional landing content, label, and position. Keep the real node and its native children; do not wrap it in a synthetic category and do not repeat the landing page as an "Overview" child. - Heading-only group — no page of its own. Use
category_no_page: trueon theindex.mdx, or a synthetic{ type: "category" }sidebar item.
A synthetic type: "category" never has an href and has no property that links it to a page. Putting a landing page inside one produces an unlinked heading with the landing page duplicated as its first child.
Header Navigation Rules
Header navigation is the headerNav field of the zudoDoc({...}) call in this project's zfb.config.ts:
// zfb.config.ts
export default defineConfig(
zudoDoc({
headerNav: [
{ label: "Getting Started", path: "/docs/getting-started", categoryMatch: "getting-started" },
{
label: "Learn",
path: "/docs/guides",
categoryMatch: "guides",
children: [
{ label: "Guides", path: "/docs/guides", categoryMatch: "guides" },
{ label: "Components", path: "/docs/components", categoryMatch: "components" },
],
},
{ label: "Reference", path: "/docs/reference", categoryMatch: "reference" },
],
}),
);
- 3–6 items max. More than 6 overwhelms users and wraps the header.
- Each item is a broad section, not a page. "Guides" ✓, "How to install" ✗.
categoryMatchMUST be a single top-level directory name. Multi-segment values (e.g."platforms/xbox") break active-state highlighting. For nested grouping, use a header-level dropdown withchildren— not a path.- Dropdowns are for closely related sections only. "Learn > Guides, Components" makes sense. "Everything > 7 miscellaneous items" does not — split into separate header items instead.
categoryMatchvalues must match actual directory names —categoryMatch: "guides"requires aguides/directory under the docs content root.
For a large navigation tree, the home page's category grid can opt into a wider layout with home: { wide: true } in the same zudoDoc({...}) call.
Sidebar Structure Rules
The sidebar is generated from the filesystem. The rules are about how you organize files:
- Author an
index.mdxfor every category directory. It supplies intentional landing content and metadata; itssidebar_positionsets the category's position in the parent sidebar. Without one, a category that contains pages still gets a generated auto-index page and a linked row, but with a default label and position.category_no_page: trueremoves the page and the link. - Every page MUST set
sidebar_position. Without it, pages sort alphabetically — almost never what you want. This is the single most common AI mistake. Small integers are fine; leaving gaps (1, 2, 3, 10) makes later insertion easier. - Nesting depth: prefer 2–3 levels. Deep nesting hides content. If you need more, the header nav is probably missing a category — split it out. This is a readability rule, not an enforced limit.
- Each sidebar section covers one cohesive topic. Do not mix unrelated themes in the same section (e.g. "Hardware" and "Community Events").
- Use kebab-case directory and file names.
my-article.mdx, notmyArticle.mdx(breaks on case-sensitive filesystems) ormy_article.mdx. The URL slug derives from the filename, so kebab-case also keeps URLs clean.
Category Top Page (index.mdx)
Every category directory should have an authored index.mdx — the landing page for that category. Keep it short:
- A 1–2 sentence intro describing what the category covers.
- A
<CategoryNav category="<dir>" />component that auto-renders links to sibling pages. - No full content beyond the intro. Real documentation lives in sibling
.mdxfiles under the same directory.
---
title: Guides
sidebar_position: 1
---
Step-by-step guides for common tasks.
<CategoryNav category="guides" />
The category prop value is the category's slug relative to the docs content root — for a top-level directory this is just the directory name (e.g. "guides"), and for a nested category the slash-joined path (e.g. "guides/advanced"). It is a slug, never a filesystem path — no src/content/ prefix, no trailing slash.
Worked Example — Nav Plan First, Then Files
Building a gaming wiki? Plan the tree first:
Header Nav: Sidebar (Xbox section):
├── Home Xbox (linked to xbox/index.mdx)
├── Platforms ← dropdown ├── Hardware (linked)
│ ├── Xbox │ ├── Xbox Series X
│ ├── PlayStation │ └── Accessories
│ └── Nintendo ├── Games (linked)
├── Genres ← dropdown │ ├── Halo Infinite
│ ├── RPG │ └── Starfield
│ └── Action └── Services (linked)
└── Community └── Game Pass
Then the directory structure follows mechanically — each platform and genre gets its own top-level directory so categoryMatch matches the first URL segment:
src/content/docs/
├── home/
│ └── index.mdx
├── xbox/
│ ├── index.mdx ← the linked "Xbox" row (short intro + <CategoryNav>)
│ ├── hardware/
│ │ ├── index.mdx
│ │ ├── xbox-series-x.mdx
│ │ └── accessories.mdx
│ ├── games/
│ │ └── ...
│ └── services/
│ └── ...
├── playstation/
│ └── index.mdx
├── rpg/
│ └── ...
└── community/
└── index.mdx
Writing Rules (per page)
Frontmatter
---
title: My Page
description: A brief summary of this page.
sidebar_position: 1
---
## First Section
Your content here.
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | Yes | Page title — automatically rendered as the page h1 |
sidebar_position |
number | Strongly recommended | Sort order within category (lower = first) |
description |
string | No | Subtitle shown below the title |
sidebar_label |
string | No | Override the sidebar display label |
tags |
string[] | No | Cross-category grouping |
draft |
boolean | No | Exclude the page from the build entirely |
unlisted |
boolean | No | Built but hidden from sidebar/nav |
Frontmatter is Zod-validated at build time. The table above covers the framework-known fields; custom keys (e.g. author, status) pass through and are preserved for your own use — they just carry no built-in behavior.
No h1 in content
The frontmatter title IS the page h1, rendered automatically. Content must start with ## h2 headings. Writing # Something in the body produces a duplicate h1 and breaks the heading hierarchy, TOC, and accessibility.
Linking between documents
Use relative file paths with the .md/.mdx extension — they are resolved to correct URLs and validated at build time:
[Installation guide](./installation.mdx)
[Frontmatter fields](../guides/frontmatter.mdx#anchor)
- Do NOT use absolute paths like
/docs/foo/barin prose — the resolver cannot verify them. - Do NOT omit the extension — the resolver needs it to distinguish file links from URL links.
- External links use regular URLs as usual.
Admonitions
Available globally — no imports needed. Two syntaxes:
:::note[Optional Title]
Directive syntax — preferred in prose-heavy content.
:::
<Warning title="Be Careful">JSX syntax — preferred when nesting other JSX.</Warning>
Six types: note/<Note>, tip/<Tip>, info/<Info>, warning/<Warning>, danger/<Danger>, caution/<Caution>. All accept an optional title. (JSX additionally registers <Important>, used by GitHub-alert conversion.)
i18n (only when this project's i18n feature is enabled)
Check zfb.config.ts: if the zudoDoc({...}) call sets a non-empty locales map, i18n is on. Read defaultLocale, docsDir, and every exact locales entry (<locale-code> → { dir }). Then every page must exist in the default-locale directory and each configured additional-locale directory, mirroring the same tree — same filenames, translated prose, identical code blocks. A non-i18n scaffold has an empty locales map and no additional content directory; skip this section entirely.
Never discover current locale roots with a src/content/docs-* glob. Versioned
trees such as src/content/docs-v1 or src/content/docs-v1-ja are snapshots,
not additional locales. For the scaffold's starter prose, ja receives
Japanese text when configured; arbitrary non-EN locale codes receive English
placeholder prose pending translation. Do not describe those locales as
already translated.
Apply Japanese writing conventions only when the locale code is ja; do not
infer Japanese guidance for another code.
Carve-outs — do NOT create additional-locale mirrors for these:
- Pages with
generated: truein frontmatter (build-generated content). - Claude Resources and Codex Resources pages (when those features are enabled). Their generators write the overview and category indexes into the default and every configured locale directory themselves, and keep each resource detail page only in the default directory; locale routes show that body through fallback. Do not hand-write locale copies or locale index stubs — the generator refuses to overwrite an authored file at one of its index paths.
- Paths listed in the
defaultLocaleOnlyPrefixessetting inzfb.config.ts, if any — default-locale-only by design. It is empty unless you add prefixes; the resource features do not add any.
Common Mistakes (Do Not Do)
- Writing pages before planning the nav tree — the root cause of chaotic structures.
- Putting specific pages in the header nav. The header is for broad categories only.
- Missing
sidebar_position— unpredictable alphabetical ordering. - Missing
index.mdxin category directories — the category falls back to a generated page with a default label and position. - Wrapping a landing page in a synthetic
type: "category"— produces an unlinked heading with the landing page duplicated as its first child. - Stuffing a category
index.mdxwith full content — keep it to intro +<CategoryNav>. - Multi-segment
categoryMatch(e.g."platforms/xbox") — breaks header active-state highlighting. - Deep nesting (4+ levels) — the header nav is probably missing a category.
- Starting content with
# h1— duplicates the auto-rendered title. - Absolute
/docs/...links or extension-less links in prose — the resolver can't verify them. - camelCase/PascalCase file names — break on case-sensitive filesystems.
- Expecting a header dropdown or a list of section pages to create a sidebar parent — both leave the sections as peers. Use an umbrella tree for complete sections under one landing page.
- Reorganizing navigation via config instead of moving files — the filesystem is the default navigation; reach for an editorial tree only when URLs must stay.
- Using
<CategoryNav>for a note tray, or turning a long note tray into a topic tree by count — use<NoteTrayIndex />, and keep the sequence unless readers need topic access. - Creating a near-duplicate page — when an existing page serves the same reader task, update it.
- Copying a cross-cutting page's body into several categories — give it one primary home and link to it from the others.
- Splitting or reorganizing by page count — a large homogeneous category can be fine; reorganize only for a concrete reader problem.
Checklist Before Creating Any Page
- [ ] Have you read
AUTHORING.mdand answered its four questions? - [ ] Have you drawn (or re-read) the full navigation tree?
- [ ] Which header category does the page belong under? (If none fits, add a header category or reconsider the page.)
- [ ] Which sidebar section inside that header category?
- [ ] Does the target directory exist, with an
index.mdx? - [ ] Is
sidebar_positionset in the frontmatter? - [ ] Is the file name kebab-case?
- [ ] Does the content start with
## h2(no h1)? - [ ] If i18n is enabled: is the matching file created in every configured additional-locale directory?
Full Guides
The complete versions of this guidance (with more examples) are published in the zudo-doc showcase docs. They are optional reading: the project policy and this skill contain everything needed to place a page offline.
- Maintaining documentation structure (placement checks, structure reviews, adoption): https://github.com/zudolab/zudo-doc/blob/main/src/content/docs/guides/maintaining-documentation-structure.mdx
- Writing docs: https://zudo-doc.takazudomodular.com/docs/getting-started/writing-docs/
- Structuring navigations: https://zudo-doc.takazudomodular.com/docs/getting-started/structuring-navigations/
- Sidebar (category rows, sidebar configuration, scope recipes): https://zudo-doc.takazudomodular.com/docs/guides/sidebar/
- Editorial navigation (advanced): https://zudo-doc.takazudomodular.com/docs/guides/editorial-navigation/
- Umbrella tree (advanced): https://zudo-doc.takazudomodular.com/docs/guides/editorial-navigation/#umbrella-tree-with-complete-sections
04 同仓库更多 Skills
zudo-doc-version-bump
Bump package version, update changelog and versioned docs snapshot (if those features are enabled), commit, tag, and create a GitHub release. Use when: (1) User says 'version bump', 'bump version', 'release', or 'zudo-doc-version-bump', (2) User wants to create a new release of this project.
zudo-doc-translate
Translate zudo-doc documentation between the locales configured in this project, with Japanese conventions applied only to the `ja` locale.
zudo-doc-design-system
Project-specific CSS and component rules for zudo-doc. Must be consulted before writing or editing CSS, zudo-wind utilities, color tokens, or component markup in this project. Covers: component-first strategy, design token system, three-tier color architecture, and palette index convention. Triggered by 'design system', 'zudo-doc-design-system', 'zudo-doc-css-wisdom' (old name).
localized-shell
Fixture skill for localized generated resource routes.
zudo-doc-writing-rules
Doc-writing rules for zudo-doc content (mdx files under src/content/docs/ and src/content/docs-ja/). Consult before writing or editing doc content. Covers: no h1 in content, sidebar_position is mandatory, kebab-case file names, bilingual rule, linking conventions, and admonition syntax. Triggered by 'writing rules', 'zudo-doc-writing-rules', 'doc rule', 'mdx rule', 'write a doc', 'create a page'.
zudo-doc-version-bump
Bump the lockstep monorepo version, author package-specific changelogs, commit, tag all three packages, and create distinct GitHub releases. Use when: (1) User says 'version bump', 'bump version', 'release', or 'zudo-doc-version-bump', (2) User wants to create a new release of this monorepo.