MkDocs-Jupyter Plugin
mkdocs-jupyter is an MkDocs plugin that enables the seamless integration of Jupyter notebooks (.ipynb files) and Jupytext-generated Python scripts (.nb.py files) directly into your MkDocs documentation. It allows for rendering notebooks, optionally executing them during the build process, supports theme integration, and offers granular control over the visibility of notebook cells and outputs using tags. The current stable version is 0.26.2, with active development and regular updates.
Warnings
- gotcha MkDocs Material specific Markdown features (like admonitions, info blocks) do not render correctly within Jupyter notebook markdown cells. This is due to `nbconvert` not supporting these extensions, leading to plain text rendering.
- gotcha Enabling notebook execution (`execute: true`) can lead to build failures if required Jupyter dependencies (like `jupyter`, `nbconvert`, `ipykernel`) are not installed, if the specified `kernel_name` is unavailable, or if notebooks are excessively large, causing timeouts.
- gotcha Version incompatibilities between `mkdocs-jupyter`, `MkDocs`, `nbconvert`, and themes like `mkdocs-material` can cause plugin conflicts or rendering issues.
- gotcha By default, notebooks are not executed during the `mkdocs build` process. Their outputs will only reflect the state of the `.ipynb` file when it was last saved.
- gotcha Having both a `.ipynb` file (e.g., `example.ipynb`) and a `.md` file (e.g., `example.md`) with the same base name in your `docs` directory can lead to unexpected rendering behavior or errors.
- deprecated Older versions (prior to 0.23.0) might have issues with `nbconvert` version 7.
Install
-
pip install mkdocs-jupyter -
pip install jupyter nbconvert ipykernel
Quickstart
site_name: My Docs
nav:
- Home: index.md
- My Notebook: notebooks/example.ipynb
- My Python Script: notebooks/script.py
plugins:
- search
- mkdocs-jupyter:
execute: true # Optional: Execute notebooks during build
include_source: true # Optional: Add download link for source notebooks
kernel_name: python3 # Optional: Specify kernel to use for execution