Skip to main content

MkDocs Primer Theme

A MkDocs theme built on GitHub's Primer design system — documentation that looks like it belongs on GitHub.

Install

$ pip install mkdocs-primer
# mkdocs.yml
theme:
  name: primer

Features

  • GitHub's .markdown-body rendering — the same typography, tables and code chrome as a README on github.com.
  • Light and dark modes via Primer's color primitives, with an auto/light/dark toggle that remembers the visitor's choice. Defaults to following the OS.
  • Syntax highlighting mapped onto Primer's prettylights variables, so code colors follow the color mode. Works with both pymdownx.highlight and codehilite.
  • Copy buttons for Pygments code blocks and an accessible back-to-top control that respects reduced-motion preferences.
  • Admonitions styled after GitHub's alerts. The admonition extension ships no CSS and @primer/css has no rule for it, so most themes render !!! note undecorated.
  • Sidebar navigation with unlimited nesting, collapsed down to the section the reader is in, plus a breadcrumb trail, prev/next links, a search results page, and a 404 page.
  • Optional Workbox-powered offline support for sites served over HTTPS.
  • A footer bar under the whole layout: copyright and the "Improve this page" link from the Jekyll theme on one line, a "Made with" line under it, and a row of social links driven by a config list, drawn from a curated set of Simple Icons.
  • A metadata byline under the page title with created/updated dates (from mkdocs-git-revision-date-localized), an estimated reading time computed from the page's word count, and authors (from mkdocs-git-authors) — no blog plugin required. The line and each of its fields are independently toggleable.
  • Native support for the plugins that need it: mkdocs-section-index (section labels render as links) and mkdocs-static-i18n (translated pages get the right <html lang> and can use the header language selector). See Plugins.

Configuration

Option Default Description
logo null Image shown beside the site name, relative to docs_dir.
favicon img/favicon.svg Site icon.
locale en Language of the theme's own text. Catalogs ship for en, es, fr, hi, pt, ru and zh.
include_sidebar true Render the navigation sidebar.
show_footer true Render the footer bar.
show_footer_generator true Show "Made with mkdocs-primer and MkDocs" in the footer.
social [] Icon links shown in the footer.
show_metadata true Render the metadata line under the page title.
show_metadata_created true Show the created date.
show_metadata_updated true Show the last-updated date.
show_metadata_reading_time true Show the estimated reading time.
show_metadata_authors true Show the authors.
toc auto "Table of contents" outline: auto, expanded, collapsed or hidden.
color_mode auto Initial color mode: auto, light or dark.
light_theme light Primer theme used in light mode.
dark_theme dark Primer theme used in dark mode.

For GitHub's hover anchors next to headings, enable the toc extension with a leading permalink carrying Primer's anchor class:

markdown_extensions:
  - toc:
      permalink: ""
      permalink_class: anchor
      permalink_leading: true

(The empty permalink is deliberate — the theme supplies the octicon, and it keeps a stray out of your search results.)

See the documentation for the rest.

Development

For the package release procedure, see RELEASING.md.

The CSS under mkdocs_primer/css/vendor/ is copied from @primer/css and @primer/primitives and committed, so installing the theme needs no Node toolchain. To refresh it after bumping a version in package.json:

$ npm install
$ npm run vendor

CI fails if those committed files drift from the pinned versions.

To preview the demo site:

$ pip install -e . -r requirements-docs.txt
$ mkdocs serve --watch-theme

It is served at http://127.0.0.1:8000/mkdocs-primer/ — site_url gives the site that path, and the dev server mounts it there. --watch-theme is what makes the loop work while editing the theme: without it MkDocs watches docs/ and mkdocs.yml only, and a change under mkdocs_primer/ never reaches the browser.

VS Code users get this from .vscode/: Run Task → Serve the demo site, or F5 for the same thing with a browser attached, at full width or under the theme's 1012px breakpoint. Build every site CI builds runs the four strict builds below in order.

Offline build

The theme can register a service worker generated by Workbox. Enable offline: true under theme, build the site, then run workbox generateSW against the output directory. The included configuration is a complete example:

$ npm install
$ npm run build:offline

This precaches the generated site for offline use after the first visit. Service workers require HTTPS (or localhost), so this does not make a file:// distribution offline-capable.

The demo site doubles as the theme's plugin compatibility test: mkdocs.yml enables every plugin that needs something from a theme, and CI builds it with --strict. Those plugins need Python 3.10+, so CI checks the theme's own floor of 3.9 against a plugin-free site.

A few plugins cannot share that config — rss and gen-files both break under static-i18n, and Mermaid breaks under minify_html — so they get their own sites under examples/, published beside the main one and described on the Examples page. Build them after it, since mkdocs build cleans site/:

$ mkdocs build --strict
$ mkdocs build --strict -f examples/rss/mkdocs.yml
$ mkdocs build --strict -f examples/gen-files/mkdocs.yml
$ mkdocs build --strict -f examples/diagrams/mkdocs.yml

License

MIT. Vendored Primer CSS is MIT, Copyright (c) GitHub, Inc. — see mkdocs_primer/css/vendor/LICENSE.

Metadata

Release files for mkdocs-primer 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-primer 0.4.1
File Size Uploaded Provenance
mkdocs_primer-0.4.1.tar.gz 155.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-primer 0.4.1
File Interpreter ABI Platform
mkdocs_primer-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 341.9 kB

Release files / mkdocs_primer-0.4.1.tar.gz

Download URL mkdocs_primer-0.4.1.tar.gz
Size 155.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f43fefa48abbfac4c4da94c03ff45a54497d1374fcfbf6b166bfcbbbd4ce9f5d
BLAKE2b-256 checksum
How to use checksums
5162ed3d696f2372cebd0fbb8fb91228112242151a2f89154a78daa34843886d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / mkdocs_primer-0.4.1-py3-none-any.whl

Download URL mkdocs_primer-0.4.1-py3-none-any.whl
Size 186.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e64a07245dea509908981ddf4828462d938fe9c35b30dbea8b23d09cdd5e24a
BLAKE2b-256 checksum
How to use checksums
529a217221428442195400c5c0f85ca8f4a2713bef38ba45a2a42120147e4741
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for mkdocs-primer 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mkdocs_primer-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page