mdBook How to Customize the theme

  • First read the mdBook official documentation for theme:

    https://rust-lang.github.io/mdBook/format/theme/

  • Get the default theme for modification

    On Windows with Git Bash, run commands:

    mkdir -p EasiestSoft.com/tmp
    cd EasiestSoft.com/tmp
    mdbook init --theme
    
    tree.com //F
    
    │   book.toml
    │
    ├───book
    └───src
        │   chapter_1.md
        │   SUMMARY.md
        │
        └───theme
            │   book.js
            │   favicon.png
            │   highlight.css
            │   highlight.js
            │   index.hbs
            │
            └───css
                    chrome.css
                    general.css
                    print.css
                    variables.css    
    
    mv src/theme path/to/your/book/root/mytheme
    cd ..
    rm -rf tmp
    
  • Apply a custom theme

    Add the following line to your book.toml:

    [output.html]
    theme = "mytheme"
    
  • A full book.toml for https://www.EasiestSoft.com

[book]
title = "Easiest IT tutorial Website"
author = "EasiestSoft"
language = "en"
description = "Easy IT tutorial for Beginners"

[build]
create-missing = false
build-dir = "D:/dl/book-it"

[output.html.fold]
enable = true
level = 0

[output.html]
theme = "mytheme"
default-theme = "rust"

[output.html.search]
enable = true

#[preprocessor.toc]
#command = "mdbook-toc"
#renderer = ["html"]

©2012-2019 EasiestSoft