Guide for setting up structured documentation repositories with mdBook. Use when creating new docs repos, understanding structure, or avoiding common mistakes in technical documentation projects.
Set up structured technical documentation repositories using mdBook with proper content separation (WHAT/HOW/WHY/SPECS). Based on lessons from real projects that underwent major refactorings due to poor initial structure.
Key principle: Establish content ownership model on day 1 to prevent costly refactoring later.
Aligns with DITA framework (Darwin Information Typing Architecture):
project-root/
├── planning/ # Requirements and constraints
├── decisions/ # Architecture decisions (WHY)
├── components/ # Physical/logical component specs
├── configuration/ # System specifications (WHAT)
└── procedures/ # Implementation steps (HOW)
Why stage-based?
Alternative (not recommended): Item-based structure breaks WHAT/HOW separation.
See references/templates/agents.md for the full AGENTS.md template.
configuration/ = WHAT
procedures/ = HOW
decisions/ = WHY
components/ = SPECS
# Table of Contents. Do not use
# Section headers as sidebar dividers.Before scaffolding, gather minimal project context. This input populates book.toml, INTRODUCTION.md, and planning/requirements.md with meaningful content instead of empty placeholders.
Required:
title and README.md headingdescription and README.md overviewOptional:
This is not a formal requirements analysis. A brief statement like "compact, quiet, power-efficient homelab with PCIe expansion, dual NVMe, and 2 DIMM slots" is enough to generate useful content across multiple files.
# 1. Create structure
mkdir -p planning decisions components configuration procedures
touch README.md INTRODUCTION.md SUMMARY.md AGENTS.md
# 2. Copy templates (see references/templates/)
# 3. Create README.md in each subdirectory
# 4. Set up pre-commit hooks
# 5. Create SUMMARY.md
Done! Structure prevents 70% of common refactoring issues.
[Configuration: System](../configuration/system.md)[Components](../components/) not
[Components](../components/README.md) (mdBook compiles README.md to index.html)README.md paths for navigationCost: 135 lines deleted in real project refactoring
Wrong: Including full spec table in procedures file
Right: "For complete specifications, see Configuration: X"
Cost: 369 lines removed, 20 files updated in real project
Wrong: Configuration file with both specs AND step-by-step UI instructions
Right: Separate files - configuration/ for specs, procedures/ for steps
Cost: Content had to be moved between directories
Solution: Create README.md in each subdirectory on day 1 with (see
references/templates/subdirectory-readme.md):
Cost: 20 files updated with cross-reference changes
Wrong: device-adoption.md with generic steps
Right: switch-setup.md, module-setup.md (component-specific)
Cost: 3 major refactorings, 19 commits, ~500 lines deleted
Solution: Create AGENTS.md on day 1 documenting content ownership (see
references/templates/agents.md)
Each specification exists in exactly one place. All other files link to it.
Link to related content, don't repeat it. Add "Related Documentation" sections.
Add HTML comments: <!-- WHAT, not HOW --> to explain separation.
Every subdirectory explains its purpose and content ownership.
Automate quality checks with pre-commit hooks.
Centralize external links to prevent link rot. Start with a single RESEARCH.md file (see
references/templates/research.md). Migrate to a research/ directory when the file exceeds ~300
lines or has five or more distinct topics (see references/templates/research-readme.md and
references/templates/research-topic.md).
git initmkdir -p planning decisions components configuration procedures scriptsCopy from references/templates/ and customize:
references/templates/component.md)references/templates/configuration.md)references/templates/procedure.md)pip install pre-commitpre-commit installmdbook-setup skill for recommended settings)mdbook servemdbook buildTotal time: ~90 minutes
mdbook serve runs without errorsmdbook build completes successfullyNo. Always reference, never duplicate.
Good! Reference them: "For complete specs, see [Configuration: X]"
After setup:
Plus eliminates mental overhead of "where does this belong?"
references/directory-structure.md - Recommended directory layoutreferences/setup-checklist.md - Day 1 setup checklistreferences/templates/agents.md - AGENTS.md content ownership templatereferences/templates/bom.md - Bill of materials templatereferences/templates/component.md - Component specification templatereferences/templates/configuration.md - Configuration specification templatereferences/templates/procedure.md - Procedure (step-by-step) templatereferences/templates/readme.md - Repo-level README.md templatereferences/templates/research.md - Single-file RESEARCH.md templatereferences/templates/research-readme.md - Multi-file research/README.md index templatereferences/templates/research-topic.md - Multi-file research topic file templatereferences/templates/subdirectory-readme.md - Subdirectory README.md templatereferences/templates/summary.md - SUMMARY.md table of contents templateFor mdBook-specific setup, see the mdbook-setup skill.