DOC-32Recommended
Show the last-updated date on every docs page
Show the date each docs page last changed in its content, taken from version control or its front matter. Give the same date in the page metadata.
How to do it
A reader trusts a page from last month more than one from three years ago, and an agent can weigh them the same way. Take the date of the last commit that changed the page text, or an updated field the writer sets, never the build date. Show it near the title in a <time> element. Match the metadata as Show the same date to people and machines says. The review date and the owner are a separate field, as Give every doc an owner and a review date says.
Examples
JavaScript example
import { execFileSync } from 'node:child_process';
export const lastChanged = file =>
execFileSync('git', ['log', '-1', '--format=%cs', '--', file], { encoding: 'utf8' }).trim();
Python example
import subprocess
def last_changed(file: str) -> str:
return subprocess.run(["git", "log", "-1", "--format=%cs", "--", file],
capture_output=True, text=True, check=True).stdout.strip()
How to check
A build test reads every docs page. Its <time datetime> equals its updated field or the date of the last commit to its source. No date is later than the build.
Related rules
- SEO-21 Show the same date to people and machines in SEO
- ENG-37 Give every doc an owner and a review date in Engineering
- DOC-37 Show readers when a translation is older than the source in Documentation
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/documentation/keeping-docs-current/last-updated-date">Agent Wranglers documentation playbook</a>. In code you write, add a comment next to it with the same link.