Sphinx Last Updated by Git

0.3.8 · active · verified Wed Apr 15

sphinx-last-updated-by-git is a Sphinx extension that automatically retrieves and displays the 'last updated' timestamp for each documentation page directly from your Git repository. It considers the author date of the last relevant Git commit, including checks for included files and other dependencies to ensure the most recent timestamp. The current version is 0.3.8, and the project maintains a regular release cadence with updates addressing Sphinx compatibility and new features.

Warnings

Install

Imports

Quickstart

To quickly enable `sphinx-last-updated-by-git`, install the package and add `'sphinx_last_updated_by_git'` to the `extensions` list in your `conf.py`. Ensure your chosen Sphinx theme is configured to display the `last_updated` variable in its templates. The extension sets `html_last_updated_fmt` to an empty string by default, making the timestamp available for display.

# conf.py
import os
import sys

# Minimal Sphinx configuration
project = 'My Git Docs'
copyright = '2026, My Org'
author = 'My Org'
release = '0.1'

extensions = [
    'sphinx_last_updated_by_git',
]

# Optional: Customize the format of the last updated date
# html_last_updated_fmt = '%Y-%m-%d %H:%M:%S %Z'

# Optional: Exclude specific files/commits from last updated calculation
# git_exclude_patterns = ['**/auto_generated/*.rst']
# git_exclude_commits = ['a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0']

html_theme = 'alabaster' # Ensure your theme supports displaying 'last_updated'

# Create a simple index.rst and page1.rst in your docs directory:
# index.rst:
# Welcome to My Git Docs!
# ======================
#
# This is the main index page.
#
# .. toctree::
#    :maxdepth: 2
#    :caption: Contents:
#
#    page1
#
# page1.rst:
# My First Page
# =============
#
# This content was last updated by Git.

view raw JSON →