A modern mdBook replacement written in Rust that generates beautiful HTML documentation from Markdown files
MD-Book is the next-generation documentation generator for Rust projects. Built with performance and developer experience in mind, it combines the simplicity of mdBook with modern web capabilities.
- Multi-format support: Parse standard Markdown, GitHub Flavored Markdown (GFM), and MDX files
- Powered by markdown-rs: Fast and reliable parsing with extensive feature support
- Responsive design: Desktop to mobile optimized layouts
- Card-based navigation: Intuitive homepage with visual page cards
- Right-hand TOC: In-page table of contents for easy navigation
- Modern styling: Clean, professional appearance out of the box
- Live development server: Watch files and reload automatically
- Syntax highlighting: Server-side code highlighting with syntect
- Full-text search: Integrated Pagefind search with instant results
- Flexible templates: Tera templating engine for easy customization
- Static site generation: Deploy anywhere (Netlify, Vercel, Cloudflare Pages)
- Fast builds: Optimized Rust performance for large documentation sets
- Feature flags: Include only what you need (server, search, syntax highlighting)
- WASM support: Compile to WebAssembly for browser-based usage
cargo install md-book# Build documentation
md-book -i docs -o output
# Development mode with live reload
md-book -i docs -o output --serve --watch
# Custom port
md-book -i docs -o output --serve --port 8080git clone https://github.com/terraphim/md-book.git
cd md-book
cargo run -- -i docs -o output-i = input directory (contains your .md files)
-o = output directory (generated HTML ready for deployment)
The tool generates static HTML files that can be deployed to any static hosting service.
- Styling: Edit
src/templates/css/styles.css - Templates: Modify files in
src/templates/(standard Tera templates) - Configuration: Add
book.tomlfor advanced settings
- Nicer default styling for content - multiple columns for horizontal layout,
- Right-hand TOC to navigate around the page.
- Create index.md to create content for the home page; alternatively, it will create a list of cards with all the pages as an index.
-
Code blocks with syntax highlighting
-
Better default styling
| Feature | MD-Book | mdBook | Docusaurus | VitePress |
|---|---|---|---|---|
| Language | π¦ Rust | π¦ Rust | βοΈ Node.js | βοΈ Node.js |
| Performance | β‘ Blazing fast | β‘ Fast | π’ Slower | β‘ Fast |
| Build Time | < 1s (small) | < 2s (small) | 10-30s | 5-15s |
| Bundle Size | ~50KB | ~100KB | ~500KB | ~200KB |
| Search | β Pagefind | β Basic | β Algolia | β Built-in |
| Live Reload | β WebSocket | β Basic | β Fast Refresh | β HMR |
| MDX Support | β Native | β Limited | β Full | β Full |
| Themes | β Customizable | β Basic | β Extensible | β Vue-based |
| Deployment | β Anywhere | β Anywhere | β Optimized | β Optimized |
- Rust-native performance with minimal dependencies
- Simple setup without complex configuration
- Modern features like search and live reload
- Static deployment to any hosting platform
- Clean, fast documentation that just works
- API documentation for Rust libraries
- Project READMEs and guides
- Technical blogs and tutorials
- Internal documentation with search
- Open source projects needing fast docs
Desktop to mobile responsive design with card-based navigation.
Syntax highlighting, page navigation, and content browsing.
Full-text search powered by Pagefind with instant results.
-
Clone and build:
git clone https://github.com/terraphim/md-book.git cd md-book cargo build -
Set up pre-commit hooks (recommended):
make install-pre-commit # or manually: ./scripts/setup-pre-commit.sh -
Run quality checks:
make qa # Run all checks (format, lint, test) make dev-check # Complete development check make ci-local # Simulate CI checks locally
make help- Show all available commandsmake check- Run cargo checkmake fmt- Check code formattingmake fmt-fix- Fix code formattingmake clippy- Run clippy lintsmake test- Run unit testsmake test-integration- Run integration testsmake test-all- Run all testsmake qa- Run all quality checksmake clean- Clean build artifacts
The project includes pre-commit hooks that automatically run:
cargo fmt --all -- --check- Formatting checkcargo clippy --all-targets --all-features -- -D warnings- Lintingcargo test --lib --bins- Unit testscargo check --all-targets --all-features- Compilation check
These run automatically on every commit to ensure code quality.
You can add a book.toml file to the input directory to configure the book.
Supports TOML configuration via book.toml Allows overriding with environment variables (prefixed with MDBOOK_) Supports command-line arguments Enables shell expansion in config file paths Provides default values for optional fields Example usage:
# Using environment variables
MDBOOK_BOOK.TITLE="My Book" ./md-book -i input -o output
# Using custom config file
./md-book -i input -o output -c ~/my-config.toml
# Config values can be nested using an underscore
MDBOOK_OUTPUT.HTML.MATHJAX_SUPPORT=true ./md-book -i input -o outputThe configuration system follows the priority order:
- Command line arguments (highest priority)
- Environment variables (prefixed with MDBOOK_)
- Custom config file (if provided)
- Default book.toml
- Default values (lowest priority) you shall be able to feed config into json and yaml files.
cargo run -- -i input -o outputcargo run -- -i input -o output --watchcargo run -- -i input -o output --servecargo run -- -i input -o output --watch --serve --port 8080MD-Book supports deployment to multiple platforms:
# Setup (includes 1Password integration)
./scripts/setup-cloudflare.sh
# Deploy to production
./scripts/deploy.sh production# Build site
cargo run -- -i docs -o dist
# Deploy with CLI
netlify deploy --prod --dir=dist
# Or drag & drop at https://app.netlify.com/dropSee DEPLOYMENT.md for comprehensive deployment documentation including:
- 1Password integration for secure secret management
- GitHub Actions workflows
- Custom domains and SSL
- Performance optimization
- Platform comparison
By default, raw HTML in markdown files is disabled for security. If you enable allow_html in your configuration:
[output.html]
allow-html = trueWarning: This allows arbitrary HTML/JavaScript in your markdown files to be rendered. Only enable this if:
- You trust all content authors
- Your documentation is not user-generated
- You understand the XSS (Cross-Site Scripting) implications
The default allow-html = false setting is safe and recommended for most use cases.
We welcome contributions! See CONTRIBUTE.md for guidelines.
- π Bug Reports: Open an issue
- π‘ Feature Requests: Start a discussion
- π§ Pull Requests: Always welcome!
- Rust-specific syntax highlighting
- MathJax/LaTeX support
- Dark mode theme
- Internationalization (i18n)
- π Documentation
- π¬ Discussions
- π¦ Twitter
- Enhanced theme system
- Plugin architecture
- Multi-language support
- Advanced search filters
- Visual editor
- Collaboration features
- Analytics integration
- API documentation mode
Licensed under the MIT License.
- Built with markdown-rs for parsing
- Styled with Tera templating engine
- Search powered by Pagefind
- Inspired by mdBook
β Star this repo if MD-Book helps you create better documentation!


