#mdbook #git #date #per-page #last-modification

bin+lib mdbook-last-changed

mdbook preprocessor to add the last modification date per page

11 unstable releases (3 breaking)

0.4.0 Nov 19, 2025
0.3.1 Nov 19, 2025
0.2.2 Sep 15, 2025
0.1.4 Aug 5, 2023
0.1.1 Nov 1, 2022

#1106 in Text processing

Download history 13/week @ 2025-10-29 13/week @ 2025-11-05 28/week @ 2025-11-12 45/week @ 2025-11-19 79/week @ 2025-11-26 161/week @ 2025-12-03 148/week @ 2025-12-10 94/week @ 2025-12-17 17/week @ 2025-12-31 80/week @ 2026-01-07 52/week @ 2026-01-14 110/week @ 2026-01-21 45/week @ 2026-01-28 28/week @ 2026-02-04 25/week @ 2026-02-11

218 downloads per month

MPL-2.0 license

16KB
183 lines

mdbook-last-changed

A preprocessor for mdbook to add a page's last change date and a link to the commit on every page.

It adds a "Last change" footer, including a date and a link to the corresponding commit. It uses the configured git-repository-url as the base.

Requirements

  • The git command line tool.
  • Access to the git repository checkout while building your book.

Installation

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

cargo install mdbook-last-changed

Add it as a preprocessor to your book.toml:

[preprocessor.last-changed]
command = "mdbook-last-changed"
renderer = ["html"]

Configuration

mdbook-last-changed is configured using additional options under [output.html] and [preprocessor.last-chagned]:

[output.html]
# Optional: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"

[preprocessor.last-changed]
# git-commit-url = false # Disable linking to it
# git-commit-url = "https://git.example.com/user/project/commit/" # A custom URL, different from the repository URL
  • If git-repository-url is not configured the footer will not contain the commit and a link to it and instead only show the last changed date.
  • The commit URL is constructed as <git-repository-url>/commit/<commit-id> where <git-repository-url> is the configured URL and <commit-id> is the commit ID fetched from the local repository.
  • If the commit URL pattern is different you can set preprocessor.last-changed.git-commit-url to any URL. The commit ID will be appended to that URL.
  • If you want to disable adding the link set preprocessor.last-changed.git-commit-url = false.

Without git-repository-url configured:

<footer id="last-change">Last change: <time datetime="2023-07-09">2023-07-09</time></footer>

With git-repository-url configured:

<footer id="last-change">Last change: <time datetime="2023-07-09">2023-07-09</time>, commit: <a href="https://github.com/$user/$project/commit/$commit">0000000</a></footer>

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

[output.html]
additional-css = ["last-changed.css"]

And in last-changed.css style the <footer> element or directly the CSS element id last-changed:

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

License

MPL. See LICENSE.
Copyright (c) 2022-2025 Jan-Erik Rediger janerik@fnordig.de

Dependencies

~9–13MB
~160K SLoC