ScriptsApr 12, 2026·1 min read

mdBook — Create Books from Markdown Like Gitbook in Rust

mdBook creates online books from Markdown files, similar to Gitbook but implemented in Rust. Used for the official Rust Book, Cargo Book, Tokio Tutorial, and many open-source documentation sites. Fast builds and a clean default theme.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

cargo install mdbook
mdbook init my-book
cd my-book
mdbook serve                                # Dev server at :3000
mdbook build                                # Build to book/

Directory structure:

my-book/
├── book.toml
└── src/
    ├── SUMMARY.md
    ├── chapter_1.md
    └── chapter_2/
        ├── section_1.md
        └── section_2.md

src/SUMMARY.md:

# Summary

- [Introduction](./chapter_1.md)
- [Getting Started](./chapter_2/section_1.md)
  - [Installation](./chapter_2/section_2.md)
Intro

mdBook is a command-line tool and Rust library to create online books from Markdown files. Similar to Gitbook but implemented in Rust — fast, single binary, no Node.js required. Used for the official Rust Book, Cargo Book, Tokio Tutorial, Bevy Book, and many Rust ecosystem docs.

What mdBook Does

  • Markdown to HTML — clean default theme
  • SUMMARY.md — table of contents as navigation
  • Search — full-text search built in
  • Syntax highlighting — for code blocks
  • Preprocessors — custom Markdown transforms
  • Renderers — HTML (default), PDF, EPUB via plugins
  • Themes — customizable CSS
  • Link checking — validate internal links
  • Includes — embed file contents with {{#include}}
  • Rust code testingmdbook test runs Rust code examples

Comparison

Tool Language Speed Node.js
mdBook Rust Fast No
Gitbook JS Medium Yes
Docusaurus JS Medium Yes
VitePress JS Fast Yes
Sphinx Python Medium No

常见问题 FAQ

Q: 和 VitePress 比? A: mdBook 零依赖(单 Rust 二进制),VitePress 需要 Node.js 但支持 Vue 组件和更丰富的自定义。纯文档选 mdBook,交互式文档选 VitePress。

来源与致谢 Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets