Download Links and TOC Integration¶
The mkdocs-jupyter plugin provides seamless integration between notebook download links and table of contents generation. This feature enhances navigation and allows users to easily access source notebooks.
Configuration¶
The following settings control download links and TOC behavior:
plugins:
- mkdocs-jupyter:
include_source: true # Enable download links
toc_depth: 3 # TOC depth (1-6)
enable_default_notebooks_toc: true # Extract TOC from headings
enable_default_jupyter_toc: true # Jupyter-style TOC
How It Works¶
Download Link Generation¶
When include_source: true
is set, mkdocs-jupyter automatically:
- Creates download links at the top of each notebook page
- Preserves original notebooks in the site output
- Maintains relative paths for easy access
TOC Extraction¶
The plugin extracts headings from notebooks and integrates them with MkDocs navigation:
- Markdown cells with headings (
#
,##
, etc.) become TOC entries - Hierarchy preserved - nested headings create nested TOC items
- Automatic anchors - headings get URL-friendly IDs
Integration Features¶
Combined Navigation¶
The TOC and download links work together to provide:
- Quick navigation - Jump to any section within the notebook
- Easy access - Download source from any page
- Context preservation - TOC shows notebook structure
Security Considerations¶
When implementing download links:
Access Control
Download links inherit the same access permissions as the page itself. For restricted content, ensure proper authentication is in place.
Best Practices¶
- Consistent Headings - Use clear, descriptive headings in notebooks
- Logical Structure - Organize content hierarchically
- TOC Depth - Set appropriate
toc_depth
(usually 2-3) - File Organization - Keep notebooks in logical directories
Examples¶
Basic Implementation¶
# In your notebook's first cell:
# # My Analysis Notebook
#
# ## Introduction
# This notebook demonstrates...
#
# ## Data Preparation
# ### Loading Data
# ### Cleaning Steps
This structure generates: - A download link at the top - A TOC with proper nesting - Navigable sections
Advanced Features¶
You can control TOC behavior per notebook using cell tags:
Testing the Integration¶
To verify everything works:
- Check download links appear on notebook pages
- Verify TOC shows notebook structure
- Test navigation - clicking TOC items should scroll to sections
- Confirm downloads work and preserve formatting
Troubleshooting¶
Common issues and solutions:
Issue | Solution |
---|---|
No download link | Ensure include_source: true is set |
Missing TOC entries | Check heading syntax in markdown cells |
Broken navigation | Verify no duplicate heading IDs |
Download fails | Check file permissions and paths |
Related Features¶
- Jupyter Notebooks - Main notebook integration
- Navigation - General navigation features
- Output Preservation - Preserving notebook outputs