MkDocs Auto Tag Plugin
The mkdocs-auto-tag-plugin is an MkDocs plugin designed to automatically add tags to documentation pages based on their file path or name. It uses glob patterns and regular expressions to define rules for tag assignment. The current version is 0.1.3, released in August 2023, and it is actively maintained with a focus on MkDocs 1.x compatibility.
Warnings
- breaking MkDocs 2.0 is being rewritten without a plugin system, which will make this plugin and other existing MkDocs 1.x plugins incompatible. Material for MkDocs has already limited its version range to '<2' to avoid breakage. Plan for alternative solutions or remain on MkDocs 1.x if relying on plugins.
- gotcha There is another MkDocs plugin named `mkdocs-auto-tags` (note the plural 'tags' and hyphen) by a different author, which has similar functionality but potentially different configuration and behavior. Ensure you are installing and configuring the correct `mkdocs-auto-tag-plugin` as intended.
- gotcha The order of plugins in your `mkdocs.yml` can be critical. If you are using `mkdocs-auto-tag-plugin` in conjunction with other tag-related plugins (like the built-in `tags` plugin from Material for MkDocs), ensure `auto_tag` is placed appropriately in the plugin list, usually after any official `tags` plugin if it modifies the tag list.
- gotcha This plugin appends tags to pages based on its rules without overwriting any tags already defined in the page's front matter. If a page explicitly defines tags, the automatically generated tags will be added alongside them.
Install
-
pip install mkdocs-auto-tag-plugin
Imports
- auto_tag
plugins: - auto_tag:
Quickstart
plugins:
- auto_tag:
rules:
- pattern: '.*_API_Reference\.md$'
tags:
- 'API-Reference'
- pattern: 'dev_guide/.*'
tags:
- 'Development-Guide'
- pattern: 'docs/README.md'
tags:
- 'Home'