A Bootstrap 4 theme for MkDocs, maintained for docs.nerva.one. Some customisations and fixes on top of byrnereese/mkdocs-bootstrap4 (unmaintained upstream).
- Bootstrap 4.6.2 CSS for the layout, navbar, modals and typography.
- No jQuery, no Popper, no Bootstrap JavaScript.
js/base.jsis plain DOM code that drives the same class contract the Bootstrap bundle used (.show,.modal-backdrop,body.modal-open,[data-toggle=...]), so the CSS and any downstream overrides keep working unchanged. - No icon font. The handful of icons (moon/sun, search, arrows, brand marks) are inline SVG from Bootstrap Icons (MIT) and Simple Icons (CC0).
- highlight.js 11, self-hosted (
js/highlight.min.jsplus the grammars injs/languages/), loaded withdefer. A scoped dark palette incss/hljs-dark.csskeeps highlighted code readable in dark mode. - Dark mode with no flash of the wrong theme: a small inline script
decides before first paint from the stored choice (
localStorage, keynerva-docs-theme) or the system preference, and the navbar toggle writes the stored choice. While no choice is stored the page follows the system, and once one is the choice wins for the session. - Works with mkdocs 1.4 and up. The templates only read theme options
through attribute access with defaults, which resolves on the plain
Themeof mkdocs 1.4 as well as on the Mapping-based one of 1.5+.
Copy the mkdocs_bootstrap4 folder next to your documentation and point
mkdocs.yml at it:
theme:
name: null
custom_dir: 'nerva-docs-theme/mkdocs_bootstrap4/'
suppress_nextprev: true
For a docs checkout that expects the theme as a sibling directory, clone
this repository next to it under nerva-docs-theme/.
The package is also pip-installable (entry point bootstrap4), but it is
not published to PyPI: the distribution is named mkdocs-nerva, not
the upstream mkdocs-bootstrap4 it forks, and it is marked
Private :: Do Not Upload. Install it from a checkout when needed.
suppress_nextprev— toggles the "Next"/"Prev" page links in the header (defaulttrue: hidden, matching the theme'smkdocs_theme.yml).highlightjs— enable code highlighting (self-hosted build).hljs_style— highlight.js style to load fromcss/hljs-<style>.min.css(githubships with the theme; drop other styles next to it as needed).hljs_languages— extra grammars to load fromjs/languages/.shortcuts— key codes for the keyboard shortcuts (?,n,p,s).
The theme binds ? (shortcuts help), / (search — the key s works as
well), n (next page) and p (previous page). They are ignored while
typing in a field.
This theme makes use of the
git-committers plugin
for MkDocs. Consult that plugin's documentation for proper configuration.
Favicon path: docs/img/favicon.ico, navbar logo path: docs/img/logo.ico.
Any browser with defer, querySelector, closest, class lists and
matchMedia — in practice everything from 2017 onward. The search
worker path uses standard Web Workers; on browsers without Worker
support (vanishingly rare), search falls back to a jQuery call the theme
no longer ships, so search is unavailable there while reading is not.