A MkDocs plugin to add configurable dropdown menus to the Material theme header
Project description
MkDocs Header Dropdown Plugin
A MkDocs plugin that adds configurable dropdown menus to the Material theme header. This plugin allows you to create cross-documentation navigation menus that can be shared across multiple documentation sites.
Installation
From Source (Local Development)
pip install -e /path/to/mkdocs_header_dropdown
From Git Repository
pip install git+https://github.com/cms-cat/mkdocs-header-dropdown.git
Quick Start
Option 1: Using a Shared Config (Recommended for Organizations)
If you're part of an organization with shared documentation links:
# Add the shared config as a git submodule
git submodule add https://github.com/your-org/docs-common.git
# mkdocs.yml
plugins:
- search
- header-dropdown:
config_file: "docs-common/header-dropdown.yml"
Option 2: Direct Configuration
For standalone projects:
# mkdocs.yml
plugins:
- search
- header-dropdown:
dropdowns:
- title: "Documentation"
links:
- text: "Getting Started"
url: "/getting-started/"
- text: "User Guide"
url: "/guide/"
- text: "API Reference"
url: "/api/"
- title: "External Links"
links:
- text: "GitHub Repository"
url: "https://github.com/your-org/your-project"
target: "_blank"
That's it! The plugin automatically provides the necessary templates. No manual template overrides required.
Configuration Options
Plugin Configuration
The plugin supports two ways to configure dropdowns, which can be combined:
-
config_file(string, optional): Load dropdown configuration from a YAML file- Path is relative to the repository root
- Useful for sharing configuration across multiple repositories via git submodules
-
dropdowns(list, optional): Define dropdowns directly in mkdocs.yml
Both sources are merged together, allowing you to extend shared configs with repository-specific dropdowns.
Dropdown Configuration
Each dropdown in the dropdowns list supports:
title(string, required): The text displayed on the dropdown buttonicon(string, optional): Path to an icon image displayed next to the titlelinks(list, required): List of links in the dropdown menu
Link Configuration
Each link in the links list supports:
text(string, required): The text displayed for the linkurl(string, optional): The URL the link points to (not needed if usingsubmenu)target(string, optional): The target attribute (e.g.,_blankfor new tab)bottom-border(bool or int, optional): Add bottom divider of width 1px if true, or given value in px if numbersubmenu(list, optional): List of nested links for a submenu (see Nested Dropdowns below)
Example: Using Shared Config File
For multiple repositories that share the same dropdown configuration (e.g., via git submodule):
Step 1: Create a shared config repository with header-dropdown.yml:
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"
Step 2: Add as git submodule and reference in mkdocs.yml:
git submodule add https://github.com/your-org/cms-docs-config.git
plugins:
- header-dropdown:
config_file: "cms-docs-config/header-dropdown.yml"
Example: Multiple Dropdowns
plugins:
- header-dropdown:
dropdowns:
- title: "CMS POG Docs"
icon: "/assets/cms-logo.png"
links:
- text: "BTV Docs"
url: "https://btv-wiki.docs.cern.ch/"
target: "_blank"
- text: "JetMet TWiki"
url: "https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetMET"
- title: "External Resources"
links:
- text: "GitHub"
url: "https://github.com/cms-cat"
target: "_blank"
- text: "GitLab"
url: "https://gitlab.cern.ch/cms-analysis"
target: "_blank"
Example: Nested Dropdowns
Create submenus by using submenu:
plugins:
- header-dropdown:
dropdowns:
- title: "Resources"
links:
- text: "GitHub"
url: "https://github.com/example"
- text: "Documentation" # Not clickable, shows submenu only
submenu:
- text: "User Guide"
url: "/guide/"
target: "_blank"
- text: "API Reference"
url: "/api/"
- text: "Tutorials"
url: "/tutorials/"
Clickable Top-Level Link with Submenu
You can also make the top-level item clickable by adding a url:
plugins:
- header-dropdown:
dropdowns:
- title: "Documentation"
links:
- text: "All Docs"
url: "/docs/" # Clicking goes here
target: "_blank"
submenu: # Hovering shows submenu
- text: "User Guide"
url: "/docs/guide/"
- text: "API Reference"
url: "/docs/api/"
Nested dropdown features:
- Show an arrow indicator (▶) automatically
- Appear to the right on hover
- Top-level can be clickable (with
url) or non-clickable (withouturl) - Support multiple levels of nesting
- Work with keyboard navigation
## Features
- **Shared configuration**: Load dropdown config from external YAML files via git submodules
- **Flexible configuration**: Mix shared configs with repository-specific dropdowns
- **Nested dropdowns**: Create multi-level submenus with arrow indicators
- **Multiple dropdown menus**: Support for any number of dropdowns
- **Configurable icons and titles**: Customize appearance
- **Hover and click interactions**: User-friendly interactions
- **Responsive design**: Works on all screen sizes
- **Theme integration**: Works with Material theme's light and dark modes
- **Accessible**: Keyboard-friendly navigation
- **No manual overrides**: Plugin automatically provides necessary templates
## Requirements
- MkDocs >= 1.4.0
- Material for MkDocs theme
## License
MIT License
## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_header_dropdown-0.4.0.tar.gz.
File metadata
- Download URL: mkdocs_header_dropdown-0.4.0.tar.gz
- Upload date:
- Size: 133.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
755172e54e192c50ce00ba11015fd27feb4f1f2eeaa1fc450b7a623c194e0a67
|
|
| MD5 |
f89e0569963b0d2079e8a6a60251fc25
|
|
| BLAKE2b-256 |
6a803a914ef6b8181c43318a832e2c4cd3ae64a56bdb3624eae65d5b523fba16
|
Provenance
The following attestation bundles were made for mkdocs_header_dropdown-0.4.0.tar.gz:
Publisher:
cd.yml on cms-cat/mkdocs-header-dropdown-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_header_dropdown-0.4.0.tar.gz -
Subject digest:
755172e54e192c50ce00ba11015fd27feb4f1f2eeaa1fc450b7a623c194e0a67 - Sigstore transparency entry: 1200359703
- Sigstore integration time:
-
Permalink:
cms-cat/mkdocs-header-dropdown-plugin@9cf09639ca64774337069050e61ce3f7ac3ec15e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/cms-cat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@9cf09639ca64774337069050e61ce3f7ac3ec15e -
Trigger Event:
release
-
Statement type:
File details
Details for the file mkdocs_header_dropdown-0.4.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_header_dropdown-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cbac576b9d3b09f57599573c517702919904db307ad90e83fb616ff7444eb8c
|
|
| MD5 |
c65628b48dd5d900b859530180d90d34
|
|
| BLAKE2b-256 |
b1e60c96d49f24ef843fa88ea96998155b1ce07502d6318a5c99012e59bcfbed
|
Provenance
The following attestation bundles were made for mkdocs_header_dropdown-0.4.0-py3-none-any.whl:
Publisher:
cd.yml on cms-cat/mkdocs-header-dropdown-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_header_dropdown-0.4.0-py3-none-any.whl -
Subject digest:
0cbac576b9d3b09f57599573c517702919904db307ad90e83fb616ff7444eb8c - Sigstore transparency entry: 1200359777
- Sigstore integration time:
-
Permalink:
cms-cat/mkdocs-header-dropdown-plugin@9cf09639ca64774337069050e61ce3f7ac3ec15e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/cms-cat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@9cf09639ca64774337069050e61ce3f7ac3ec15e -
Trigger Event:
release
-
Statement type: