MkDocs Mermaid2 Plugin
An MkDocs plugin (current version 1.2.3) for seamlessly embedding Mermaid.js diagrams within Markdown source files, rendering them dynamically in your generated documentation. It is actively maintained with regular updates, enabling complex diagrams like flowcharts, sequence diagrams, and gantt charts directly in your MkDocs site.
Warnings
- deprecated The `extra_javascript` parameter in `mkdocs.yml` for specifying the Mermaid JavaScript library is deprecated as the primary method.
- gotcha When explicitly declaring plugins in `mkdocs.yml`, you must list *all* desired plugins, including default ones like `search`, which would otherwise be implicitly enabled. Failing to do so will deactivate `search`.
- gotcha The `mkdocs-mermaid2-plugin` is not compatible with `mkdocs-minify-plugin`.
- breaking Configuration arguments for Mermaid.js versions >= 10.0.0 did not work correctly in plugin versions prior to 1.0.8.
- gotcha MkDocs versions older than 1.5.0 may have issues correctly calling Mermaid.js ESM (ECMAScript Module) libraries.
Install
-
pip install mkdocs-mermaid2-plugin
Imports
- mermaid2
Configured in mkdocs.yml under 'plugins'
Quickstart
### mkdocs.yml
plugins:
- search
- mermaid2
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid_custom
### docs/index.md
# My Project Documentation
Here's a simple flowchart:
```mermaid
graph TD
A[Start] --> B{Process?};
B --> C{Decision};
C --> D[End];
```