MkDocs Jupyter Plugin
Render Jupyter notebooks as documentation pages.
Core Attributes
Plugin Name
mkdocs-jupyter
Repository
What It Does
This plugin converts Jupyter notebook (.ipynb) files into documentation pages. It renders saved notebook outputs - it does NOT run a live Jupyter server.
Not a Live Server
The plugin displays pre-executed notebook content. Set execute: true in config to run notebooks during build (use with caution).
Configuration
plugins:
- mkdocs-jupyter:
include_source: true
execute: false
allow_errors: false
ignore_h1_titles: false
include_requirejs: true
Usage
Basic Usage
Place notebooks in your docs directory:
docs/
├── index.md
├── tutorials/
│ ├── introduction.ipynb
│ └── advanced.ipynb
└── examples/
└── data-analysis.ipynb
Notebooks appear in navigation automatically!
Creating Good Notebook Docs
Structure:
1. Markdown cell: Title and introduction
2. Code cell: Imports
3. Markdown cell: Explanation
4. Code cell: Example code
5. Output cell: Results
6. Markdown cell: Summary
Example Notebook
Cell 1 (Markdown):
Cell 2 (Code):
Cell 3 (Markdown):
Cell 4 (Code):
Configuration Options
include_source
Show code cells: true or false
execute
Run notebooks during build: false (recommended) or true
allow_errors
Continue build on errors: true or false
ignore_h1_titles
Skip first H1 heading: true or false
include_requirejs
Include RequireJS for widgets: true or false
Features
Rendered Content
The plugin preserves: - Code cells with syntax highlighting - Output cells (text, tables, plots) - Markdown cells - LaTeX equations - HTML output - Interactive widgets (with RequireJS)
Supported Output Types
Text:
DataFrames:
Plots:
HTML:
Best Practices
1. Clear All Unnecessary Outputs
Before committing:
Then re-run only the cells you want to show.
2. Use Markdown Liberally
Add context between code cells:
3. Keep Notebooks Focused
One topic per notebook: - data-loading.ipynb - data-cleaning.ipynb - visualization.ipynb
4. Add Metadata
Use notebook metadata for configuration:
5. Test Notebook Flow
Restart kernel and run all cells before committing:
6. Optimize Cell Outputs
- Limit DataFrame display rows
- Use reasonable plot sizes
- Clear debug outputs
- Save large results to files
7. Add Requirements
Document required packages:
Execute Mode
Use Execute Mode Carefully
Setting execute: true runs notebooks during build. This can:
- Slow down builds significantly
- Cause non-deterministic failures
- Require all dependencies in build environment
When to use execute mode: - Notebooks are fast (<1 second) - Outputs change frequently - Automated testing of notebooks - CI/CD validation
When NOT to use: - Long-running computations - Notebooks with external dependencies - Random or time-dependent outputs - Production documentation
Interactive Widgets
For interactive Jupyter widgets:
Requires:
Troubleshooting
Notebook Not Rendering
Check:
1. File extension is .ipynb
2. Notebook is in docs directory
3. JSON is valid (not corrupted)
Missing Outputs
Solutions:
1. Re-run cells in Jupyter
2. Save notebook with outputs
3. Check include_source setting
Widget Not Working
Solutions:
1. Enable include_requirejs
2. Use compatible widget versions
3. Check browser console
Tips
- Save notebooks with outputs before committing
- Use clear, descriptive cell outputs
- Add explanatory markdown cells
- Keep execution time short
- Document dependencies
- Test in fresh environment