The mkdocs-header-dropdown plugin allows you to add configurable dropdown menus to your MkDocs Material theme header. This is perfect for organizations with multiple documentation sites that need cross-linking navigation.
# For local development
pip install -e /path/to/mkdocs-header-dropdown-plugin
# OR from Git repository (once published)
pip install git+https://gitlab.cern.ch/cms-analysis/mkdocs-header-dropdown.gitAdd this to your mkdocs.yml:
plugins:
- search
- header-dropdown:
dropdowns:
- title: "CMS POG Docs"
icon: "/assets/CMSlogo_white_nolabel_1024_May2014.png"
links:
- text: "Analysis Corrections | CrossPOG"
url: "https://cms-analysis-corrections.docs.cern.ch/"
target: "_blank"
- text: "BTV Docs"
url: "https://btv-wiki.docs.cern.ch/"
target: "_blank"# Create overrides directory if it doesn't exist
mkdir -p overrides/partials
# Copy the dropdown template
cp /path/to/plugin/templates/partials/header-dropdown.html overrides/partials/If you don't have a custom header already, also copy the header template:
cp /path/to/plugin/templates/partials/header.html overrides/partials/If you DO have a custom header, add this line where you want the dropdown:
{% include "partials/header-dropdown.html" %}Make sure your mkdocs.yml has:
theme:
name: material
custom_dir: overrides# Build the site
mkdocs build
# Or serve locally
mkdocs serveUse the new local serve script:
./serve-local.shThis script:
- Uses your locally installed plugin
- Initializes submodules if needed
- Generates correction digest
- Starts the dev server on http://127.0.0.1:8000
The original serve.sh has been updated to work with the plugin:
./serve.shThis script:
- Mounts the plugin directory into the Docker container
- Installs the plugin in the container
- Runs mkdocs serve
Solution: Make sure you installed the plugin in your current Python environment:
pip install -e /path/to/mkdocs-header-dropdown-pluginVerify installation:
pip list | grep mkdocs-header-dropdownSolution:
- Check that you copied
header-dropdown.htmltooverrides/partials/ - Verify you have
custom_dir: overridesin your theme config - Make sure your header includes
{% include "partials/header-dropdown.html" %}
If you get file not found errors related to systematics:
git submodule update --init --recursive- See USAGE.md for detailed configuration options
- See DEPLOYMENT.md for sharing across projects
- See README.md for full documentation
Here's a complete example with multiple dropdowns:
theme:
name: material
custom_dir: overrides
plugins:
- search
- header-dropdown:
dropdowns:
# Primary dropdown for POG docs
- title: "CMS POG Docs"
icon: "/assets/cms-logo.png"
links:
- text: "Analysis Corrections"
url: "https://cms-analysis-corrections.docs.cern.ch/"
target: "_blank"
- text: "BTV Wiki"
url: "https://btv-wiki.docs.cern.ch/"
target: "_blank"
- text: "Muon Wiki"
url: "https://muon-wiki.docs.cern.ch/"
target: "_blank"
# Secondary dropdown for tools
- title: "Tools"
links:
- text: "GitLab"
url: "https://gitlab.cern.ch/cms-analysis"
target: "_blank"
- text: "GitHub"
url: "https://github.com/cms-cat"
target: "_blank"