A MkDocs plugin that enriches your sitemap.xml and search index with git revision dates. It automatically injects the last commit date for each page based on git history, making your sitemap SEO-friendly and search results more informative.
- π Sitemap enrichment: Automatically updates sitemap
<lastmod>dates with git revision dates - π Search index enrichment: Adds formatted git dates to search results
- π
Flexible date formatting: Choose from
date,datetime,iso_date,iso_datetime, or custom formats - π Timezone & locale support: Display dates in any timezone and language
- π― Theme agnostic: Works with any MkDocs theme
- β‘ Independent formatting: Search index dates are formatted independently from page display dates
- π Seamless integration: Works alongside
mkdocs-git-revision-date-localized-plugin
Install the plugin using pip:
pip install mkdocs-metadata-enricher-pluginOr with uv:
uv add mkdocs-metadata-enricher-pluginplugins:
- search
# Must run BEFORE metadata-enricher to provide git data
- git-revision-date-localized:
type: date
enable_creation_date: false
# Our plugin for enriching sitemap & search index
- metadata-enricher:
enrich_sitemap: true
enrich_search: true
search_date_type: datetime
search_locale: enmkdocs buildThat's it! Your sitemap.xml and search index will now include git revision dates.
| Option | Type | Default | Description |
|---|---|---|---|
enrich_sitemap |
bool | True |
Add git dates to sitemap.xml <lastmod> tags |
enrich_search |
bool | True |
Add formatted dates to search index entries |
When enrich_search: true, you can customize how dates appear in search results:
| Option | Type | Default | Description |
|---|---|---|---|
search_date_type |
str | iso_date |
Date format: date, datetime, iso_date, iso_datetime, or custom |
search_custom_format |
str | %d. %B %Y |
Python strftime format when search_date_type: custom |
search_timezone |
str | UTC |
Timezone for date display (e.g., Europe/Amsterdam) |
search_locale |
str | en |
Locale code for date localization (e.g., en, de, fr) |
2021-04-27
2021-04-27 13:11:28
April 27, 2021
April 27, 2021 13:11:28
27/04/2021
site_name: My Documentation
docs_dir: docs
site_dir: site
plugins:
- search
- git-revision-date-localized:
type: date
timezone: Europe/Amsterdam
locale: en
- metadata-enricher:
enrich_sitemap: true
enrich_search: true
search_date_type: datetime
search_timezone: Europe/Amsterdam
search_locale: en
search_custom_format: "%d. %B %Y" # Only used if search_date_type: customOut-of-the-box MkDocs generates sitemaps and search indexes with build dates, not actual revision dates. This is suboptimal for:
- SEO: Search engines prefer pages with accurate
<lastmod>timestamps - User experience: Users want to know when docs were actually updated
- Search results: Search indexes don't show update information
This plugin:
- Extracts the actual last commit date for each page from git history
- Injects it into
sitemap.xmlfor SEO benefits - Formats and adds it to the search index so users see up-to-date info
- Works independently with flexible date formatting
- MkDocs >= 1.0
- Python >= 3.9
- Git (for reading commit history)
- mkdocs-git-revision-date-localized-plugin >= 0.14.0
- Python 3.9, 3.10, 3.11, 3.12
- MkDocs themes: Material, ReadTheDocs, any theme
Contributions are welcome! See DEVELOPMENT.md for how to set up your development environment.
MIT License - see LICENSE for details.
- mkdocs-git-revision-date-localized-plugin - Displays git revision dates on pages
- mkdocs-material - Material Design theme for MkDocs