14 releases
Uses new Rust 2024
| 0.3.0 | Nov 27, 2025 |
|---|---|
| 0.2.0 | Apr 29, 2024 |
| 0.1.9 | Jan 23, 2024 |
| 0.1.8 | Dec 30, 2023 |
| 0.1.4 | Jul 15, 2022 |
#1140 in Text processing
446 downloads per month
160KB
192 lines
mdbook-pagetoc
A mdbook plugin that provides a table of contents for each page. Uses css/js from mdBook-pagetoc.
Show me

Notes:
-
Only supports the
htmlrenderer. -
On the first run of
mdbook build, it creates two filespagetoc.cssandpagetoc.js. -
You can customize any of them after the first run.
-
mdbook 0.5 now ships with built-in support for showing the page table of contents in the sidebar, see PR 2822
Configuration:
-
Add to
book.tomlconfig:[preprocessor.pagetoc] scroll_offset = 10 # pixels added to scroll position for active header detection (default: 10) [output.html] additional-css = ["theme/pagetoc.css"] additional-js = ["theme/pagetoc.js"] -
The place marker
<div class="sidetoc"><nav class="pagetoc"></nav></div>will be inserted inside the<main>tag. ie. This replaces<main> {{{content}}} </main>with:
<main><div class="sidetoc"><nav class="pagetoc"></nav></div> {{{content}}} </main> -
If not customizing, you may want to add entries as appropriate to
.gitignoreto keep your repo clean:theme/pagetoc.css theme/pagetoc.js -
Customization: To autohide when only single header, add this snippet to
pagetoc.css:a[class^="pagetoc-H"]:only-child { display: none; } -
Customization: To hide a header from the table of content:
## Hidden from TOC {.toc-ignore}
Acknowledgments
Alternative
Dependencies
~9–14MB
~176K SLoC