Skip to main content

Actions Status PyPI - Python Version PyPI PyPI - Downloads codecov GitHub contributors PyPI - License

mkdocs-enumerate-headings-plugin

MkDocs Plugin to enumerate the headings (h1-h6) across MkDocs pages.

👉 If you're looking to add heading numbers to your site to support exporting to single-page standalone HTML or a PDF file, have a look at mkdocs-print-site-plugin instead!

Features 🌟

  • Automatically number all headings and (optionally) give each page an sequential chapter number
  • Great for writing (technical) reports
  • Compatible with plugins like awesome-pages and monorepo
  • Compatible with markdown_extensions like pymdownx.snippets
  • Compatible with themes like mkdocs-material
  • Easy to customize styling through CSS

demo screencast

Setup

Install the plugin using pip:

pip3 install mkdocs-enumerate-headings-plugin

Next, add the following lines to your mkdocs.yml:

plugins:
  - search
  - enumerate-headings

MkDocs executes plugins in the order they are defined. If you use any other plugins that alter the navigation, make sure to define them before the enumerate-headings plugin.

If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set.

Usage

enumerate-headings will increment the chapter number for each new page (in the order they appear in the navigation) and enumerate all subheadings (unless you disable in this in the options).

There is only one requirement: make sure each markdown page starts with a level 1 header (see how to write markdown headers). Some MkDocs themes will handle this for your automatically, inserting the page title as a heading 1 if you do not specify one. If a heading 1 is still missing, you'll get a helpful error.

Pages with multiple level 1 headings are allowed and the chapter numbers will increment accordingly.

Note this plugin does not affect your markdown files, only the rendered HTML.

Styling

All heading numbers are wrapped in <span class='enumerate-headings-plugins'></span> and can be styled using CSS. See customizing a MkDocs theme on how to add an CSS to your theme.

As an example you can make the numbering lighter than the heading title by saving the CSS snippet below to a file and adding it to your MkDocs site using the extra_css setting in your mkdocs.yml file.

/* Extra CSS for mkdocs-enumerate-headings-plugin */ 
.enumerate-headings-plugin {
  filter: opacity(35%);
}

Options

You can customize the plugin by setting options in mkdocs.yml:

plugins:
    - enumerate-headings:
        toc_depth: 0
        strict: true
        start_level: 1
        increment_across_pages: true
        include:
          - "*"
        exclude:
          - index.md
          - another_page.md
        restart_increment_after:
          - second_section.md
  • toc_depth (default 0): Up to which level the table of contents should be enumerated as well. Default is 0, which means the TOC is not enumerated at all. Max is 6 (showing all enumeration)
  • start_level (default 1): First heading level that receives a visible number (1–6). Use 2 to skip numbering on the page title (H1) and start at H2, so the first subsection is 1. instead of 1.1 when each page has a single H1. Tiers above start_level are omitted from the displayed label; the first omitted slot also holds the cross-page chapter counter, so with increment_across_pages: true that chapter digit is no longer shown in the label. For per-page 1, 2, … style numbering on H2+, pair start_level: 2 with increment_across_pages: false (or accept that chapter order is not reflected in the visible prefix).
  • strict (default true): Raise errors instead of warnings when first heading on a page is not a level one heading (single #) and your MkDocs theme has not inserted the page title as a heading 1 for you. Note that in strict: false mode the heading numbers might be incorrect between pages and before and after a level 1 heading.
  • increment_across_pages (default true): Increment the chapter number for each new page (in the order they appear in the navigation). If disabled, each page will start from 1.
  • include (default ["*"]): Specify a list of page source paths (one per line) that should have enumeration (included in processing by this plugin). This can be useful for example to include enumeration on only one directory. The source path of a page is relative to your docs/ folder. You can also use globs instead of source paths. For example, to include docs/subfolder/page.md specify in your mkdocs.yml a line under include: with - subfolder/page.md
  • exclude (default not specified): Specify a list of page source paths (one per line) that should not have enumeration (excluded from processing by this plugin). This can be useful for example to remove enumeration from the front page. The source path of a page is relative to your docs/ folder. You can also use globs instead of source paths. For example, to exclude docs/subfolder/page.md specify in your mkdocs.yml a line under exclude: with - subfolder/page.md
  • restart_increment_after (default not specified): Specify a list of page source paths (one per line) where enumeration should be restarted. This can be useful if you have multiple reports or tutorials in one mkdocs site. Paths behave as with exclude (can use globs).

Contributing

Contributions are very welcome! Please read CONTRIBUTING.md before putting in any work.

Credits: This plugin was inspired by ignorantshr/mkdocs-add-number-plugin, which focuses on enumerating single selected pages.

Metadata

Release files for mkdocs-enumerate-headings-plugin 0.7.0

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-enumerate-headings-plugin 0.7.0
File Size Uploaded
mkdocs_enumerate_headings_plugin-0.7.0.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-enumerate-headings-plugin 0.7.0
File Interpreter ABI Platform
mkdocs_enumerate_headings_plugin-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.2 kB

Release files / mkdocs_enumerate_headings_plugin-0.7.0.tar.gz

Download URL mkdocs_enumerate_headings_plugin-0.7.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e63c5cf868de3d2c735ea4a0874c70b7f3214053f05248c1e22cb7bc8850f44
BLAKE2b-256 checksum
How to use checksums
8fce6b2b9ee8f42fe40a74898c1a24f3192debb7ac6da38e00b9d8ef617296a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 26, 2026.

Transparency log

Release files / mkdocs_enumerate_headings_plugin-0.7.0-py3-none-any.whl

Download URL mkdocs_enumerate_headings_plugin-0.7.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3c644cdf736d0bfc3468dc7b5b4838870462038039e7fa3b2fd6910e9519c32
BLAKE2b-256 checksum
How to use checksums
086c2b9fe10a9e2a27e72f88291f6f6957db09215d6782a758785cf1ce40ba6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

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