Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

mdBook Installation Guide

mdBook is a command-line tool to create online books with Markdown. This guide will show you how to install mdBook on your system.

Prerequisites

Before installing mdBook, you'll need one of the following depending on your installation method:

  • Rust and Cargo: You need Rust 1.70 or later installed on your system
  • Install Rust from rustup.rs

For Package Manager Installation:

  • Package manager specific to your operating system (Homebrew, Snap, etc.)

For Binary Installation:

  • No additional prerequisites required

Installation Methods

This is the most reliable method as it ensures you get the latest version with all features.

Step 1: Install Rust (if not already installed)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

Step 2: Install mdBook

cargo install mdbook

Optional: Install additional renderers

# For PDF output support
cargo install mdbook-pdf

# For presentation slides
cargo install mdbook-presentation

# For Mermaid diagrams
cargo install mdbook-mermaid

Method 2: Using Package Managers

On macOS with Homebrew:

brew install mdbook

On Linux with Snap:

sudo snap install mdbook

On Arch Linux:

sudo pacman -S mdbook

On Ubuntu/Debian (via cargo-deb):

# First install cargo-deb
cargo install cargo-deb

# Then install mdbook
cargo deb --install mdbook

On Windows with Chocolatey:

choco install mdbook

On Windows with Scoop:

scoop install mdbook

Method 3: Pre-built Binaries

  1. Go to the releases page: Visit mdBook releases on GitHub

  2. Download the appropriate binary:

    • For Linux: mdbook-v[version]-x86_64-unknown-linux-gnu.tar.gz
    • For macOS: mdbook-v[version]-x86_64-apple-darwin.tar.gz
    • For Windows: mdbook-v[version]-x86_64-pc-windows-msvc.zip
  3. Extract and install:

    # Linux/macOS
    tar xzf mdbook-v[version]-x86_64-unknown-linux-gnu.tar.gz
    sudo mv mdbook /usr/local/bin/
    
    # Or add to your PATH
    mkdir -p ~/.local/bin
    mv mdbook ~/.local/bin/
    

Method 4: Building from Source

For the latest development version or custom builds:

# Clone the repository
git clone https://github.com/rust-lang/mdBook.git
cd mdBook

# Build and install
cargo install --path .

Verification

After installation, verify that mdBook is working correctly:

Check mdBook version:

mdbook --version

You should see output like:

mdbook v0.4.40

Build the book:

# Generate static HTML files
mdbook build

# Or serve locally with live reload
mdbook serve

View the book:

  • Built files are in the book/ directory
  • When using mdbook serve, visit http://localhost:3000