#mdbook #open #mdbook-preprocessor

bin+lib mdbook-open-on-gh

mdbook preprocessor to add a open-on-github link on every page

20 stable releases

2.4.2 Dec 13, 2023
2.4.1 Aug 5, 2023
2.3.3 Feb 14, 2023
2.3.1 Dec 18, 2022
1.0.1 Jan 30, 2020

#629 in Text processing

Download history 80/week @ 2023-10-30 51/week @ 2023-11-06 57/week @ 2023-11-13 72/week @ 2023-11-20 126/week @ 2023-11-27 54/week @ 2023-12-04 117/week @ 2023-12-11 73/week @ 2023-12-18 92/week @ 2023-12-25 56/week @ 2024-01-01 41/week @ 2024-01-08 50/week @ 2024-01-15 41/week @ 2024-01-22 90/week @ 2024-01-29 58/week @ 2024-02-05 132/week @ 2024-02-12

328 downloads per month
Used in mdbook-dtmo

MPL-2.0 license

204 lines


A preprocessor for mdbook to add a open-on-github link on every page.

It adds an "Edit this file on GitHub" link on the bottom of every page, linking directly to the source file. It uses the configured git-repository-url as the base.


If you want to use only this preprocessor, install the tool:

cargo install mdbook-open-on-gh

Add it as a preprocessor to your book.toml:

command = "mdbook-open-on-gh"
renderer = ["html"]


mdbook-open-on-gh is configured using additional options under [output.html]:

# Required: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"

# Your git branch. Defaults to `main`
git-branch = "main"

# The text to use in the footer.
# The link text is marked by `[]`
open-on-text = "Found a bug? [Edit this page on GitHub.]"

To style the footer add a custom CSS file for your HTML output:

additional-css = ["open-in.css"]

And in open-in.css style the <footer> element or directly the CSS element id open-on-gh:

footer {
  font-size: 0.8em;
  text-align: center;
  border-top: 1px solid black;
  padding: 5px 0;

This code block shrinks the text size, center-aligns it under the rest of the content and adds a small horizontal bar above the text to separate it from the page content.

Finally, build your book as normal:

mdbook path/to/book


Copyright (c) 2020-2022 Jan-Erik Rediger janerik@fnordig.de


~338K SLoC