#lastupdated date incorrect

3 messages · Page 1 of 1 (latest)

covert ingot
#

I have an astro+starlight documentation website on GitHub with lastUpdated set to true in the astro config in order to see when a page was last updated. However when accessing the deployed website, all the lastUpdated pages show the same date which seems to be the current date. For example, in the git history a page updated 6 months ago still shows today as last updated.

patent fernBOT
#

Hi @covert ingot. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

This usually happens because GitHub Pages builds use a shallow Git clone, so Starlight can’t read full commit history and falls back to “now,” making every page show the same current date. Starlight’s lastUpdated relies on your repository’s Git history and may be inaccurate on platforms performing shallow clones (e.g., GitHub Actions/Pages) unless adjusted (lastUpdated config). To fix or work around:

  • Ensure full Git history is available during your build (disable shallow clone in your workflow). Otherwise, dates may be wrong due to shallow clones (Astro recipe note, Starlight config note).
  • Alternatively, override per page with frontmatter:
    ---
    lastUpdated: 2022-08-09
    ---
    
    (must be a valid YAML timestamp) (frontmatter lastUpdated).

If you can’t guarantee full history on your host, consider adding your own last-modified pipeline (e.g., a remark plugin that reads Git or filesystem mtime) and render that instead; note that Git-based solutions share the same shallow-clone caveat (recipe overview, recipe details).

You can verify availability of a page’s last updated Date via route data (starlightRoute.lastUpdated) which will be undefined or incorrect if history isn’t present (route data).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: