skillfed

mkdocs-macros-plugin

Unleash the power of MkDocs with macros and variables

mkdocs-macros-plugin v1.5.0 2.5M downloads/30d#3,053 on PyPI410
Permissive license MIT Active released

What it is and what it does

mkdocs-macros-plugin transforms MkDocs markdown pages into Jinja2 templates, allowing you to embed variables, call Python functions as macros, and use conditional logic and loops directly in your documentation. Variables can be defined globally in mkdocs.yml or external YAML files, or locally within individual pages; macros and custom filters are written as Python functions and invoked as template directives. The plugin also supports pluglets—lightweight Python packages that extend functionality without requiring separate MkDocs plugins.

This is useful when your documentation needs dynamic content (pricing tables, version-specific instructions, generated lists), reusable content blocks, or custom HTML extensions (buttons, embeds, formatted callouts). The plugin handles undefined variables gracefully by default but can be configured to fail strictly. It integrates into the standard MkDocs build pipeline and is listed as a high-quality plugin in the official MkDocs catalog.

Use it for:

  • Generate pricing or product tables with formulas applied to base values using macro functions
  • Maintain version-specific documentation by conditionally rendering sections based on variables
  • Create reusable content snippets (e.g., common disclaimers, formatted code examples) via macros
  • Embed custom HTML elements (buttons, video embeds, styled callouts) without writing raw HTML
  • Build pluglets to package and share documentation extensions across multiple MkDocs projects

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Extends MkDocs with Jinja2 templating to use variables and macros in markdown pages, enabling dynamic content generation and custom syntax extensions.

Yes. The plugin is actively maintained, widely adopted (2K+ dependent repositories), has zero known vulnerabilities, and installs with low friction. It is production-stable and well-suited for documentation projects that benefit from templating—particularly those needing dynamic content, reusable blocks, or custom syntax. Install it if your MkDocs site requires variables, macros, or conditional rendering.

Install

mkdocs-macros-plugin on PyPI

pip

pip install mkdocs-macros-plugin

uv

uv add mkdocs-macros-plugin

poetry

poetry add mkdocs-macros-plugin

Installing mkdocs-macros-plugin

Before you install

Low friction installation with a pure Python wheel. Active maintenance with a recent release and 410 repository stars. Supports Python 3.8 through 3.12 and integrates cleanly into MkDocs 1.0+.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it safe for both open-source and commercial documentation projects.

Quickstart

pip install mkdocs-macros-plugin

Then in mkdocs.yml:
plugins:
  - search
  - macros

In a markdown page:
{{ unit_price }} EUR
{{ price(unit_price, 50) }} EUR

Requires MkDocs >= 1.0 and Python >= 3.8. The plugin must be declared in mkdocs.yml to function.

Verify before relying

  • Whether custom macro functions defined in main.py are automatically discovered or require explicit registration
  • Performance impact when processing large documentation sites with many variables and macros
  • Compatibility with MkDocs themes that have custom template rendering pipelines

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 10 — hjson, jinja2, mkdocs, packaging, pathspec, python-dateutil, pyyaml, requests, super-collections, termcolor
Maintenance actively maintained — 274 days since the last release
Last repo commit
First released
Downloads 2,467,826/month — #3,053 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mkdocs_macros_plugin-1.5.0-py3-none-any.whl

Keywords: macros, markdown, mkdocs, python

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

mkdocs variables and macrosjinja2 templating for mkdocsdynamic markdown content generationmkdocs plugin templatingmarkdown macro expansionmkdocs custom syntaxtemplate variables in documentation
mkdocs-pluginjinja2-templatingdocumentation-automation

More Documentation packages

docutils

Docutils converts plaintext documentation in…

unclear · top 1,000 on PyPI

Sphinx

Sphinx generates professional documentation…

permissive · top 1,000 on PyPI

griffe

Griffe extracts the complete structure and…

permissive · top 1,000 on PyPI

sphinxcontrib-serializinghtml

A Sphinx extension that outputs documentation…

permissive · top 1,000 on PyPI

alabaster

Alabaster is a clean, responsive Sphinx theme…

permissive · top 1,000 on PyPI

sphinxcontrib-htmlhelp

A Sphinx extension that generates HTML help…

permissive · top 1,000 on PyPI

mkdocs-embed-external-markdown

A MkDocs plugin that fetches and embeds…

permissive · top 15,000 on PyPI

mkdocs-markdownextradata-plugin

Injects mkdocs.yml extra variables into…

permissive · top 15,000 on PyPI

mkdocs-meta-manager

A MkDocs plugin that automatically applies meta…

permissive · top 5,000 on PyPI

mkdocs-table-reader-plugin

A MkDocs plugin that inserts tables from…

permissive · top 15,000 on PyPI

mkdocs-video

A MkDocs plugin that embeds videos in…

permissive · top 15,000 on PyPI

copier-template-extensions

Extends Copier's Jinja2 templating with a…

permissive · top 15,000 on PyPI

mkdocs-gen-files

MkDocs plugin that generates documentation…

permissive · top 5,000 on PyPI

mkdocs-simple-hooks

A MkDocs plugin that lets you define custom…

permissive · top 15,000 on PyPI

copier-templates-extensions

Provides a Jinja2 extension for Copier that…

permissive · top 15,000 on PyPI

mkdocs

MkDocs generates static HTML documentation…

permissive · top 5,000 on PyPI