# Show a Last Updated Date from Git History on Eleventy Posts

Yes. An agent adds an updated date to each post from its last git commit, shown only when it differs from the publish date, and fixes the deploy clone depth.

[Run this on Rush](https://cloud.getrush.ai/run/add-last-modified-dates/eleventy/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent begins with how the blog already handles dates, since the new date has to sit beside the old one without replacing it. In a site built from 11ty/eleventy-base-blog, every post sets `date` in front matter (`2018-05-01` in `firstpost.md`, `2023-01-23` in the draft `fifthpost.md`), `_config/filters.js` formats it with the Luxon-based `readableDate` and `htmlDateString` filters, and `_includes/layouts/post.njk` renders it as a `<time>` element inside the `post-metadata` list, followed by the tags. Eleventy itself offers `date: "git Last Modified"`, which resolves `page.date` to the file's latest commit, but using it would move the publish date every time a typo is fixed and reorder `collections.posts`, so the agent keeps `page.date` as the publish date and adds a second value.

It adds the second value where the directory's shared data already lives, `content/blog/blog.11tydata.js`, as an `eleventyComputed.updated` function that runs `git log -1 --format=%cI -- <inputPath>` for the post's `page.inputPath` and returns the commit date, with one in-memory cache per build so a site with many posts shells out once per file and not once per template render. A file with no commit yet, such as a post being drafted during `npm run start`, gets no `updated` value instead of today's date, which is the fallback Eleventy's own `git Last Modified` would use. The agent keeps the function in the data file rather than `eleventy.config.js` because the base blog's config already delegates filters to `_config/filters.js` and has no computed data of its own.

In `post.njk` the agent adds a second `<time>` after the publish date, labelled Updated, wrapped in a condition that compares `updated` to `page.date` through `htmlDateString` so a post committed once, or edited the day it was published, shows one date rather than two identical ones. It also adds `updated` to the Atom feed, which `eleventy.config.js` builds with `@11ty/eleventy-plugin-rss` from the ten newest posts: the feed plugin takes the collection as it is, so the agent checks the plugin's version in `package-lock.json` and documents in the description whether the entry `updated` element can be overridden there or is left to the plugin.

Then it looks at where the site is built, because a git-based date is only as good as the clone. `.github/workflows/gh-pages.yml.sample` checks out with `actions/checkout` at its default depth of one commit, which would give every post the same date: the deploy commit. The agent adds `fetch-depth: 0` to that step in the sample file and notes `netlify.toml` and `vercel.json` in the description for anyone deploying there. To prove the feature it runs `npm ci` on Node 22 from `.nvmrc` and `npm run build` in its sandbox on a full clone, then reads `_site/blog/firstpost/index.html` and quotes both `<time>` elements with the real commit dates the repository's history produces.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a last-updated date to every blog post in this Eleventy site, taken from the file's most recent git commit, without changing the publish date in page.date. Read eleventy.config.js, _config/filters.js, content/blog/blog.11tydata.js, _includes/layouts/post.njk and .github/workflows first. Compute the value once per file per build with git log and cache it, leave it unset for uncommitted files, render it in post.njk only when it differs from the publish date, and make sure the deploy workflow clones with full history so the dates are right in CI. Build the site in the sandbox on the Node version in .nvmrc and quote the two dates from one built post. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch changing three files: `content/blog/blog.11tydata.js` with the computed `updated` value and its cache, `_includes/layouts/post.njk` with the conditional second `<time>`, and `.github/workflows/gh-pages.yml.sample` with `fetch-depth: 0` on the checkout step. `eleventy.config.js` and the posts' front matter are untouched, so every existing permalink and the order of `collections.posts` stay the same.

The description quotes the `post-metadata` block from one built post showing the publish date and the updated date, both from the repository's real history, and from another post whose two dates match, showing one `<time>` only. It explains the fallback for uncommitted files and the clone-depth change in a sentence each, and reports the build's summary line so a reviewer can see the extra `git log` calls did not change the build time in a way that matters.

Before merging, a reviewer checks that the deploy actually clones with history, since a shallow clone makes every date the deploy date, and decides whether the Updated label should also appear on `about.md`, which uses the home layout and is left alone by default.

## Run it on every terminal hand-off

An author who just edited a three-year-old post and wants readers to see that it was revised starts this from the terminal with this body and the repository in `resources`, then goes back to writing. The run reads the real layouts and the real deploy workflow, so the date lands in the existing metadata list and CI is fixed in the same pull request.

Send a `request_id`, a UUID, in the body so a retried start returns the run it already began. When the turn ends, `GET /o/{org}/sessions/{id}` names the pull request, and a follow-up through `POST /o/{org}/sessions/{id}/messages`, for example to add the date to the feed entries too, wakes the parked sandbox where it left off.

## Why run it on Rush?

The obvious one-liner, `date: "git Last Modified"`, is the wrong tool here because it replaces the publish date and resorts the archive, and the obvious shell-out, one `git log` per render, is slow on a large blog and wrong on a shallow CI clone. The agent reads how dates flow through `filters.js` and `post.njk`, caches the lookup, and finds the clone-depth problem in the deploy workflow before a reader does.

On Rush the build runs in the agent's own sandbox on a full clone of the repository, so the dates it quotes in the pull request are the ones readers will see, and the transcript keeps the build output and the HTML it read. The same body works on any Eleventy site that commits its posts, each in its own sandbox with its own pull request.

## Frequently asked questions

### Does this change the publish date or the order of posts?

No. `page.date` still comes from each post's `date` front matter, so `collections.posts`, the previous-and-next links and the archive order are unchanged. The updated date is a separate `updated` value computed per file and shown only when it differs from the publish date.

### What does a post show on a shallow clone?

The deploy commit's date on every post, which is why the pull request sets `fetch-depth: 0` on the checkout step in the GitHub Pages workflow sample. On another host, check that its build clones with history; the description names `netlify.toml` and `vercel.json` as the files to look at.

### Will a drafting session during npm run start break?

No. A file with no commit yet has no `git log` entry, and the computed value is left unset rather than defaulting to the current time, so the template's condition hides the Updated label until the post is committed.

### Can the updated date go into the Atom feed?

The feed in `eleventy.config.js` comes from `@11ty/eleventy-plugin-rss`, which builds each entry from the collection item. The agent checks the installed plugin version for an override hook and either wires `updated` in or documents that the plugin owns that element. Ask for it in the prompt if the feed matters to you.

## More Eleventy jobs

- [Add Lighthouse CI to an Eleventy Site](https://getrush.ai/run/add-lighthouse-ci/eleventy/)
- [Check for Broken Links in an Eleventy Site's CI](https://getrush.ai/run/add-link-checking/eleventy/)
- [Add an llms.txt File to an Eleventy Site](https://getrush.ai/run/add-llms-txt/eleventy/)

## More jobs like this: Hand off a long task

- [Add Last Updated Dates to an mdBook Site](https://getrush.ai/run/add-last-updated-dates/mdbook/)
- [Show Last Updated Dates on MkDocs Pages](https://getrush.ai/run/add-last-updated-dates/mkdocs/)
- [Show Last-Updated Dates on a Pelican Blog](https://getrush.ai/run/add-last-updated-dates/pelican/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
