Skip to main content

mkdocs-primer

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, prev/next links, a search results page, and a 404 page.
  • Optional Workbox-powered offline support for sites served over HTTPS.
  • "Improve this page" footer, as in the Jekyll theme, with a "Last updated" line when mkdocs-git-revision-date-localized is enabled.
  • 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.
include_sidebar true Render the navigation sidebar.
show_footer true Render the "Improve this page" footer.
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

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 — so they get their own sites under examples/, published beside the main one. 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

License

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

Release files for mkdocs-primer 0.1.2

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.1.2
File Size Uploaded
mkdocs_primer-0.1.2.tar.gz 91.5 kB Details

Built distribution (wheel)

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

Total release size: 190.8 kB

Release files / mkdocs_primer-0.1.2.tar.gz

Download URL mkdocs_primer-0.1.2.tar.gz
Size 91.5 kB
Tags Source
SHA-256 checksum
How to use checksums
545da302ea7c397b16df99d4682519eb7e46325b4cde4040906dc75cd7159052
BLAKE2b-256 checksum
How to use checksums
2c2bf5eb5a2aa75145a7346ef71fd1893778fea7a27fe213b5c8575ecfe8545c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

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

Download URL mkdocs_primer-0.1.2-py3-none-any.whl
Size 99.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
798d7ca5ed838ab01c6c133ad00e3ba48cce7a3820afcadce941c1d4823b7354
BLAKE2b-256 checksum
How to use checksums
7e5c23ce272f29166de7a53ff25959904d1eab18cf4f58def766ad2294480cb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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