Documentation Book (book)
The book workload compiles folders of Markdown manuscripts into structured, responsive, book-shaped documentation portals.
Powered by Krewire's native pkg/book engine (github.com/krewire/krewire/pkg/book), the book engine operates with zero external dependencies and compiles hundreds of documentation pages into static HTML in less than 15 milliseconds.
Architectural Characteristics
- Pure Go Standard Library: Zero npm scripts, no Python runtime, and no Node.js dependencies.
- Automated Chapter Ordering: Files and directories with numeric prefixes (
01-overview,02-guide) are automatically converted into numbered chapters and subchapters with clean URL slugs. - Responsive Navigation & Search: Built-in collapsible sidebar, quick chapter search filter, keyboard shortcut navigation (
/to search), and breadcrumbs. - Instant Live Authoring:
krew devorkrew serveprovides a local HTTP server that re-renders Markdown files dynamically on browser refresh. - Dark & Light Theming: Built-in theme switcher with automatic OS preference detection and
localStoragepersistence.
Scaffolding a book Project
krew new my-book --book
cd my-book
Directory layout:
my-book/
โโโ krewire.yaml # Project configuration
โโโ content/ # Documentation manuscript files
โโโ 01-introduction/
โ โโโ index.md # Chapter 1 overview
โ โโโ 01-welcome.md # Subchapter 1.1
โ โโโ 02-setup.md # Subchapter 1.2
โโโ 02-architecture/
โ โโโ index.md # Chapter 2 overview
โ โโโ 01-layers.md # Subchapter 2.1
โโโ 03-api/
โโโ index.md # Chapter 3 overview
Chapter Ordering Rules
The book engine uses deterministic naming rules to generate human-friendly navigation:
| Directory or File Name | Number | Slug | Display Title |
|---|---|---|---|
01-introduction |
1 | introduction |
1. Introduction |
01-welcome.md |
1.1 | welcome |
1.1 Welcome to the Guide |
02-getting-started |
2 | getting-started |
2. Getting Started |
01-installation.md |
2.1 | installation |
2.1 Installation |
[!NOTE] Titles are extracted automatically from the first
# Headingin each Markdown file. If no heading is present, the slug is formatted as the title.
Frontmatter Support
The book compiler tolerates YAML frontmatter blocks, allowing manuscript files to be shared seamlessly with SSG collections:
---
title: "Installation Guide"
description: "How to set up the toolchain on Linux and macOS"
date: "2026-10-08"
---
# Installation Guide
Follow the instructions below to install the binaries...
The frontmatter is automatically stripped before Markdown rendering, ensuring clean HTML output.
Configuration (krewire.yaml)
project:
name: "ecosystem-docs"
version: "0.1.0"
# Source directory containing markdown manuscripts
input: "content"
build:
output: ".krewire/build"
base: "/"
Native CLI Usage (kiw)
Build and serve your book directly with kiw:
# Build book to output directory
krew build
# Serve book locally with live re-rendering
krew serve