mkdocs-git-latest-changes-plugin
MkDocs plugin that allows you to display a list of recently modified pages from the Git log
Features
- Get all files of your MkDocs project currently in git with their file path, commit message, commit timestamp, commit hash and author.
- Sort by commit timestamp descending.
- Convert this to a markdown table.
- Substitute the marker string
{{ latest_changes }}
with this markdown table. - Enjoy your latest changes table rendered by your MkDocs theme.
Configuration
# mkdocs.yml plugin configuration example
plugins:
- git-latest-changes:
limit_to_docs_dir: True
repo_vendor: gitea
enabled_on_serve: True
history_limit: 5
timestamp_format: "%Y-%m-%d %H:%M"
table_features:
- "page_path_link"
- "timestamp"
- "author"
- "message"
-
limit_to_docs_dir
Limit
{{ latest_changes }}
to your pages in yourdocs_dir
and exclude the git history information for other files from your project repository via plugin configlimit_to_docs_dir
.
Boolean, defaults toFalse
. -
repo_vendor
Set the "vendor" of your remote repository (currently supported:
bitbucket
,github
,gitlab
andgitea
) viarepo_vendor
to get linkified commit hashes and filepaths. If not set,repo_name
is used. -
enabled_on_serve
Not amused by slow builds during
serve
while developing your docs? Disable this plugin only when running MkDocs viamkdocs serve
and only trigger this plugins functionality on builds (mkdocs build
).
Boolean, defaults toTrue
. -
history_limit
Not interested in all the old commits? Limit the table of recent changes using
history_limit = N
.N
should be a positive integer, negative values or zero disables this option.
Integer, defaults to-1
. -
timestamp_format
Format of the timestamp in the generated recent changes table.
String, defaults to%Y-%m-%d %H:%M:%S
. -
table_features
The "table_features" define the columns and their order.
Available features:
- "filepath"
- "file_link_git_repo"
- "page_path_link"
- "timestamp"
- "author"
- "message"
- "commit_hash_link"
List, defaults to:
- "file_link_git_repo"
- "timestamp"
- "author"
- "message"
- "commit_hash_link"
Hints
- This plugin depends of having any commits in the current git branch.
- An error will be raised/rendered if no git repository exists.
- For linked git commit hashes and filenames, the MkDocs config variable
repo_url
must be set and point your repository. - Relax warnings with
--no-strict
(via MkDocs strict configuration, cli), e.g. if a expected file is not in the git working tree. - Log level: Request debug information for this plugin via MkDocs
--verbose / -v
command line flag. - If you want to spare your audience git and the technical aspects of your repo: Configure your recent changes table e.g. via:
- git-latest-changes:
limit_to_docs_dir: True
timestamp_format: "%Y-%m-%d %H:%M"
table_features:
- "page_path_link"
- "timestamp"
- "author"
- "message"
CI/CD
Use in a CI environment may require some tweaking and fixes situations where the git history is not available (e.g. "HEAD is a detached symbolic reference as it points to <commit hash>
):
# GitLab / .gitlab-ci.yml
job:
script:
# Returning to branch from detached HEAD
- git switch $CI_COMMIT_REF_NAME
- <your CI script>
variables:
GIT_DEPTH: 0 # [1]
GIT_STRATEGY: clone # [2]
- [1] https://docs.gitlab.com/ee/ci/runners/configure_runners.html#shallow-cloning
- [2] https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy
Latest changes demo
Code
# docs_dir/file.md
{{ latest_changes }}
Rendered
Page/File | Date | Author | Description | Commit |
---|---|---|---|---|
docs/index.md | 2025-05-11 18:35:18 | Thomas Breitner | Fixed YAML code blocks | 305832a |
src/mkdocs_git_latest_changes_plugin/git_adapter.py | 2025-05-11 18:23:01 | Thomas Breitner | datetime.date.fromisoformat only supported YYYY-MM-DD in Python<3.11 | a7c95d7 |
src/mkdocs_git_latest_changes_plugin/plugin.py | 2025-05-11 16:11:49 | Thomas Breitner | Adjust column header | bb9805b |
src/mkdocs_git_latest_changes_plugin/presentation.py | 2025-05-11 16:11:49 | Thomas Breitner | Adjust column header | bb9805b |
tests/test_mkdocs_git_latest_changes_plugin.py | 2025-05-11 16:08:34 | Thomas Breitner | Split table_feature tests to three dedicated tests | 113c37a |
src/mkdocs_git_latest_changes_plugin/models.py | 2025-05-10 10:55:46 | Thomas Breitner | Re-enabled checking supported repository vendors and remote repo link builder | bf329bf |
src/mkdocs_git_latest_changes_plugin/templates/recent_changes_table.md.j2 | 2025-05-10 10:55:46 | Thomas Breitner | Re-enabled checking supported repository vendors and remote repo link builder | bf329bf |
mkdocs.yml | 2025-05-10 10:54:53 | Thomas Breitner | Enabled commit hash link in demo | f16b78b |
src/mkdocs_git_latest_changes_plugin/helpers.py | 2025-05-06 20:17:58 | Thomas Breitner | Removed print statements | 02d50f0 |
pyproject.toml | 2025-05-06 19:18:12 | Thomas Breitner | Mention that jinja2 is already a dependency of MkDocs | e5d9c73 |
.github/FUNDING.yml | 2024-12-27 21:33:36 | Thomas Breitner | Added funding | bc1b0e8 |
.github/workflows/deploy.yml | 2024-10-16 19:20:16 | Thomas Breitner | Run tests regardless of branch, only run ghpages for the main branch | ed0c473 |
.github/workflows/ghpages.yml | 2024-10-16 19:20:16 | Thomas Breitner | Run tests regardless of branch, only run ghpages for the main branch | ed0c473 |
.github/workflows/tests.yml | 2024-10-16 19:20:16 | Thomas Breitner | Run tests regardless of branch, only run ghpages for the main branch | ed0c473 |
README.md | 2024-06-01 16:13:58 | Thomas Breitner | New config option: history_limit | e43a563 |
.pre-commit-config.yaml | 2024-06-01 14:02:26 | Thomas Breitner | Bumped pre-commit hooks and freezed GitPython version | ff6373e |
docs/subdir/index.md | 2024-01-12 10:42:24 | Thomas Breitner | Added sub directory to test new config option | c987c89 |
.gitignore | 2024-01-10 07:01:54 | Thomas Breitner | src-based directory layout | c9a468d |
src/mkdocs_git_latest_changes_plugin/init.py | 2024-01-10 07:01:54 | Thomas Breitner | src-based directory layout | c9a468d |
docs/test.md | 2023-12-17 12:48:18 | Thomas Breitner | Some prose for test.md | 4b0cccf |
LICENSE | 2023-12-17 12:45:29 | Thomas Breitner | Add traditional LICENSE file to allow github to pick it up | 1b07bbb |
LICENSES/CC0-1.0.txt | 2023-12-02 18:16:43 | Thomas Breitner | REUSE-compliance | a2981f6 |
LICENSES/MIT.txt | 2023-12-02 18:16:43 | Thomas Breitner | REUSE-compliance | a2981f6 |