mkdocs-git-revision-date-plugin is an MkDocs plugin that automatically retrieves and displays the last Git revision date for each Markdown page in an MkDocs site. It provides the revision date in ISO (YYYY-mm-dd) format for use in page templates or directly within Markdown files. As of version 0.3.2, it is considered to be in maintenance mode, with more feature-rich development continuing in the `mkdocs-git-revision-date-localized-plugin` fork.
pip install mkdocs-git-revision-date-pluginNo compatibility data collected yet for this library.
Add the plugin to your `mkdocs.yml` file under the `plugins` section. The revision date can then be accessed in Markdown files using the `{{ git_revision_date }}` Jinja2 variable, or in theme templates via `page.meta.revision_date`. Remember to include the `search` plugin explicitly if you define any plugins.
Consider migrating to `mkdocs-git-revision-date-localized-plugin` for enhanced functionality. Install it with `pip install mkdocs-git-revision-date-localized-plugin` and update your `mkdocs.yml` to `plugins: - git-revision-date-localized`.
Adjust your CI/CD workflow to ensure a full Git history clone. Example for GitHub Actions: `actions/checkout@v4 with: fetch-depth: 0`.
Monitor official MkDocs documentation and the Material for MkDocs blog for migration strategies and potential alternatives when MkDocs 2.0 is released. You may need to pin your `mkdocs` dependency to `<2` to avoid automatic upgrades.
Ensure your `plugins` section in `mkdocs.yml` includes `search`, e.g., `plugins: - search - git-revision-date`.
Ensure Git is installed and added to your system's PATH. Confirm your MkDocs project directory is a Git repository (run `git init` and commit some files if not). For CI/CD environments, ensure a full Git history is fetched (e.g., `actions/checkout@v4 with: fetch-depth: 0` for GitHub Actions).
Correct the YAML indentation and ensure the plugin is listed correctly at the top level of your `mkdocs.yml` file. Remember to include other default plugins like 'search' if you previously relied on MkDocs enabling them automatically. ```yaml plugins: - search - git-revision-date ```
First, ensure the plugin is correctly configured in `mkdocs.yml` (see previous fix). If using in a Markdown file, `{{ git_revision_date }}` should render automatically. If using in a custom theme template, integrate `{{ page.meta.revision_date }}` within your theme's HTML files (e.g., `main.html` or a partial) using Jinja2 syntax like:
```jinja2
{% if page.meta.revision_date %}
<small>Last updated: {{ page.meta.revision_date }}</small>
{% endif %}
```