Set <lastmod> to the time the page's content last changed in a way a reader or crawler would care about, taken from a value you store when someone edits the page. Do not take it from build time, deploy time, or the moment the sitemap was generated. Google uses <lastmod> only if it is consistently and verifiably accurate [1], so one wrong source, such as a build timestamp applied to every URL, can make the whole field useless. If you cannot produce a trustworthy date for a URL, omit the element for that URL.

What Google and the protocol say

  • Google uses <lastmod> only when the value is consistently and verifiably accurate, for example when it matches the page's actual modification time [1].
  • It should reflect the last significant update. Changing only a copyright year is not significant [1].
  • Main-content, structured-data, or link changes generally warrant a new date. Minor sidebar or footer text changes do not [2].
  • If a page changed years ago but the sitemap says yesterday, Google may stop trusting the signal [2].
  • Google describes the right moment as when content has changed enough to merit a recrawl [6].
  • The protocol says lastmod is the date the linked page was modified, not the date the sitemap was generated [3].
  • Google does not use changefreq or priority at all [2]. They cannot make up for a missing or dishonest lastmod.

Pick a date source

Work through this for each URL type.

  1. Is the page a hand-edited or CMS-managed document (post, doc page, product description)? Use a stored "content last changed" field. Update it on edits to the body, structured data, or links, not on every save.
  2. Is it a static file with no CMS? Use the file's actual update date [4]. In CI, a fresh checkout often resets file modification times to checkout time, so take the date from version history for that file or from a stored field, not from the filesystem.
  3. Is it generated from data (category, tag, search-result, or listing page)? Use an approximate date based on the underlying data changing [4]. In practice that is the newest updated_at among the items the page shows.
  4. Is there no reliable timestamp? Leave <lastmod> out. The element is optional in the protocol, and an absent date makes no claim. A false date does.

Good, better, best

SourceQualityWhy
Build or generation timeWrongChanges for every URL on every run. The protocol says not to use the generation date [3].
Filesystem mtime of built outputPoorReflects the last build or checkout, not an edit.
Git or file history of the source fileGoodTracks real edits, but also counts template-only or typo commits.
Database updated_atGoodAccurate if nothing touches it for trivial reasons, such as view counters or cache warmers.
Dedicated content_updated_at fieldBestYou control when it moves, and you can keep it separate from layout changes.

Content timestamps vs. deploy timestamps

A deploy timestamp answers "when did we last ship code." A content timestamp answers "when did this page's substance last change." A site-wide template change, such as a new footer, a new nav item, or a bumped asset hash, touches every page's rendered HTML but changes the substance of none of them. Google's guidance puts those sidebar and footer edits outside what needs a new lastmod [2].

A workable rule for what moves content_updated_at:

  • Moves it: rewritten or added paragraphs, changed prices or specs, changed structured data, added or removed links in the main content.
  • Does not move it: footer or sidebar text, a copyright year, CSS or script changes, a cache purge, a re-save with no edit.
  • Your call: typo fixes. Google's wording is "significant" [1], so apply a consistent threshold and record it.

If you also expose dateModified in JSON-LD, it should agree with the sitemap value. Keeping the two aligned is covered in how to update old blog posts without faking freshness, and JSON-LD errors that hide structured data lists the date mistakes that make markup unreliable.

How sitemaps end up stamped with "now"

The usual cause is a sitemap generator that has no per-page date and falls back to the current time. Check your own generator's documentation and output rather than assuming its default.

Before:

const entries = pages.map(p => ({
  loc: p.url,
  lastmod: new Date().toISOString(), // every URL, every build
}));

After, with a fallback chain:

const entries = pages.map(p => {
  const entry = { loc: p.url };
  const date = p.contentUpdatedAt ?? p.sourceCommitDate ?? null;
  if (date) entry.lastmod = new Date(date).toISOString();
  return entry; // no date known: no lastmod
});

The fallback order matters: a stored content date first, then the date of the last commit that touched that page's source file, then nothing. Never fall through to new Date().

Generators that read page timestamps are only as honest as the timestamp. VitePress, for example, emits <lastmod> in its sitemap when the lastUpdated option is enabled [5]. The value depends on a source-page timestamp you turn on, not on a judgment about significance. Enabling the option does not make the dates meaningful, so spot-check the output.

Audit your current sitemap

Run this on any OS with Python 3. It counts how many distinct lastmod values your sitemap has and how many URLs have none:

import sys, urllib.request, collections
import xml.etree.ElementTree as ET

NS = "{http://www.sitemaps.org/schemas/sitemap/0.9}"
with urllib.request.urlopen(sys.argv[1]) as r:
    root = ET.fromstring(r.read())

dates, missing = collections.Counter(), 0
for u in root.iter(NS + "url"):
    lm = u.find(NS + "lastmod")
    if lm is None or not (lm.text or "").strip():
        missing += 1
    else:
        dates[lm.text.strip()] += 1

print(f"URLs: {sum(dates.values()) + missing}, no lastmod: {missing}, distinct values: {len(dates)}")
for value, n in dates.most_common(5):
    print(n, value)

On macOS or Linux, a quick version:

curl -s https://example.com/sitemap.xml | grep -o '<lastmod>[^<]*' | sort | uniq -c | sort -rn | head

Read the result like this:

  • One value on nearly every URL, matching your last deploy: the sitemap is stamped with build time.
  • Values that change between two runs with no edits in between: the date is computed at request time.
  • A varied spread of dates: a good sign, but pick five URLs and compare each date against the page's real edit history.

Run the script before and after a deploy that changes one page. Only that page's date should move.

Sitemap indexes

In a sitemap index, <lastmod> identifies when the sitemap file itself changed, not when the pages inside it changed [3]. Treat it as a property of the child file and update it when that file changes. The page-level dates live in the child sitemaps. Size limits apply separately: a sitemap file or index is capped at 50,000 entries and 50 MB [4].

Format

W3C Datetime is the required format, and the date-only form YYYY-MM-DD is valid [4]. Full timestamps with a timezone are fine:

<url>
  <loc>https://example.com/guide</loc>
  <lastmod>2025-03-14T09:30:00+00:00</lastmod>
</url>

Use a date-only value if you only know the day. Don't pad it with a made-up time.

What to do next

  1. Run the audit script on your live sitemap and note the distinct-value count.
  2. Find where your generator gets lastmod and remove any fallback to the current time.
  3. Add a content_updated_at field, or choose an existing field and define what moves it.
  4. Re-run the script before and after a one-page edit to confirm only that URL changes.

For the rest of the file's structure, see the XML sitemap guide. If you are checking more than dates, the technical SEO checklist includes the other sitemap checks.