Checking sitemaps and canonical URLs after a site migration

In late February 2026, I migrated rajiv.com from Hugo to Astro. The new build pipeline was cleaner, the site was faster, and the deploy went without incident. By early May, organic traffic was down meaningfully and recent posts were not ranking the way older ones did.

The generated sitemap was valid XML, but the address I advertised was wrong. My robots.txt and submission to Search Console, Google's site-owner reporting tool, still pointed to /sitemap.xml. Astro was generating a sitemap index and numbered child files. The advertised address returned 404. The Sitemaps panel had been alternating between "Couldn't fetch" and "Temporary processing error."

I inspected a sample of recent posts:

  • An article from November: "Crawled - currently not indexed." The Sitemaps row read "Temporary processing error."
  • A second article from the same week: "Discovered - currently not indexed." All crawl fields N/A.
  • A December article: indexed, with a 58 percent impressions decline flagged in the dashboard.

The site looked fine while these external observations told me to investigate. A valid local XML file and a successful build had not checked the contract between the generated site, its advertised addresses and the systems trying to read it.

The audit was bigger than the sitemap

I expanded the investigation across all three of my sites: rajiv.com and the two synthesis sites that share its infrastructure. I directed Claude Code to run five agents in parallel, each inspecting a distinct part of the SEO surface: robots.txt directives, sitemap structure and dates, structured data, canonicals, archive indexability, Open Graph tags, image alternatives and headings. They wrote into one consolidated findings document. I reviewed every finding, adjusted severities and decided what went into the release.

I classified ten findings as CRITICAL, with a longer tail of HIGH and MEDIUM findings:

  • /sitemap.xml returned 404 across all three sites.
  • Blog posts had no JSON-LD Article schema.
  • Sitemap entries lacked lastmod dates.
  • Archive pages were indexable and competing with canonical articles in my search results.
  • Some titles repeated the site name.
  • The site-brand template produced a second <h1> on each page.
  • Body images lacked alt attributes.
  • Some articles used relative canonical declarations where I wanted absolute URLs.
  • One synthesis site's robots.txt had no Sitemap: directive.
  • Articles on one site lacked og:image metadata.

Some findings exposed defects; others showed that the new templates had not carried forward my chosen site policies. A successful render and astro build had not tested those expectations.

One coordinated release

I shipped the CRITICAL and HIGH repairs together across the three Astro repositories. Shared infrastructure made it sensible to fix the common patterns together, then check each site's outputs.

I kept /sitemap.xml as the public address and added a same-site Cloudflare rewrite serving sitemap-index.xml there with status 200. I added Article, Person, WebSite and BreadcrumbList structured data from frontmatter. I applied my archive policy with noindex, follow and excluded those pages from the sitemap. A makeAbsolute() helper made canonical declarations explicit.

I also removed repeated site names from titles, changed the site-brand <h1> to a <span>, removed the generic site-wide keywords tag, added the www-to-apex 301 redirect and added article:published_time, article:modified_time and article:author to article layouts. Each piece took an evening or less. The combined deployment was a session of focused work.

Check the address and the contents

A sitemap index lists other sitemap files; those files list page URLs. Astro's sitemap integration documents output such as sitemap-index.xml and sitemap-0.xml. Testing only the first numbered file can miss pages in another child.

Choose the sitemap address you intend to advertise, then check that robots.txt and any search-tool submissions agree with it. The filename need not be /sitemap.xml; Google's sitemap guidance permits other names. In this site's May source, a hosting rule maps /sitemap.xml to /sitemap-index.xml with status 200. Cloudflare documents this kind of same-site proxy rule. Request the advertised address from the host and inspect the response as well as the generated files.

For content coverage, start with an independently specified list of the pages you intend to include. Reading the expected list from the sitemap itself would make an omitted page invisible to the test. Parse the index, read every referenced child, and compare their combined URL set with that inventory. Include other intended pages, such as the homepage, or explicitly restrict both sides to the same article subset.

Next check each page's canonical declaration: the preferred address it asks search engines to associate with that content. A declaration beginning with https:// can still point to the wrong page or host. Compare it with the expected target for that page. Google's canonical guidance accepts relative references but recommends absolute ones. An absolute address makes this comparison easier; the declared preference does not determine Google's final canonical choice.

September 2026 source review and exercise: The comparison below and the later-source observations distinguish the May implementation from the September 26 snapshots.

A comparison you can run

This Python example is entirely synthetic. The sets stand in for URLs already extracted from two sitemap children, and the dictionary stands in for canonical declarations already extracted from HTML. It reads no files and makes no requests. Its whole sitemap consists of two articles, both intended to name themselves as canonical. A site that deliberately consolidates duplicate pages needs a separate expected canonical target for each page.

Save the following as synthetic-coverage-check.py:

"""Synthetic comparison only: no files, network requests or configuration changes."""

import argparse
import sys

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("fixture", choices=("broken", "corrected"))
args = parser.parse_args()

alpha = "https://example.test/alpha/"
beta = "https://example.test/beta/"
obsolete = "https://example.test/obsolete/"

# These are the intended indexable articles, recorded independently of the output.
expected = {alpha, beta}

# Pretend these sets were read from both children of a sitemap index.
children = {"part-a.xml": {alpha}, "part-b.xml": {obsolete}}

# Pretend these values were extracted from each article's canonical declaration.
canonicals = {alpha: obsolete, beta: beta}

if args.fixture == "corrected":
    children["part-b.xml"] = {beta}
    canonicals[alpha] = alpha

listed = set().union(*children.values())
problems = []
for url in sorted(expected - listed):
    problems.append(f"Missing from sitemap: {url}")
for url in sorted(listed - expected):
    problems.append(f"Unexpected in sitemap: {url}")
for url in sorted(expected):
    actual = canonicals.get(url)
    if actual != url:
        problems.append(f"Wrong canonical for {url}: {actual}")

if problems:
    print("\n".join(problems))
    sys.exit(1)

print("PASS: the synthetic URL sets and canonical declarations agree.")

Running python3 synthetic-coverage-check.py broken produces:

Missing from sitemap: https://example.test/beta/
Unexpected in sitemap: https://example.test/obsolete/
Wrong canonical for https://example.test/alpha/: https://example.test/obsolete/

The process exits with status 1, indicating failure. With corrected instead of broken, both the second sitemap child and the first article's canonical are repaired in memory. The process prints its agreement message and exits with status 0.

The example teaches the comparison. A production implementation also has to extract and validate XML and HTML, handle missing or malformed inputs, and apply the site's URL policy consistently. A green result cannot compensate for silently skipping an unreadable child sitemap.

What the May checker actually checked

I wrote scripts/seo-check.js, about 250 lines of Node.js, to check the built site. It ran in under a second on my 340-article site. The twelve-part contract I wanted it to enforce was broader than the May implementation: that source checks several useful properties, including duplicate site names in titles, heading counts, article indexability, canonical syntax, an article-type string in JSON-LD and an absolute Open Graph image address. It also contains site-specific archive and robots.txt rules.

PropertyBehavior in the May source
Article coverage in the sitemapNo comparison between a content inventory and sitemap entries
Presence of lastmodNo lastmod check
Title lengthNo title-length check
Image alt textNo image-alt check
Missing descriptionsReported as warnings
Canonical targetChecks for an HTTPS prefix, without comparing the target
JSON-LD validityLooks for a recognized type string, without parsing the JSON

In September, copies of the May and September checker source were run against synthetic HTML and sitemap fixtures. Both returned zero for a missing sitemap article, a wrong HTTPS canonical and malformed JSON-LD containing the expected type string. Removing an <h1> supplied a positive control: both returned a failure in strict mode. These local tests show the behavior on the constructed inputs; they do not replay the May site's build or deployment.

There was a second gap at the shell boundary. The May checker defaulted to warning mode. Its hosting build branch caught even a strict-mode failure with || echo, which could print a message and return success. The ordinary build branch did not invoke the checker.

The same problem is visible with the synthetic example:

python3 synthetic-coverage-check.py broken || echo "continuing"

That command returns zero if the echo succeeds. To test propagation, use a wrapper with a harmless continuation marker:

set -euo pipefail
python3 synthetic-coverage-check.py broken
echo "continuing"

In the local test, the second wrapper returned 1 without printing its continuation. The corrected fixture let the continuation run. Apply that test to the entry point your release actually invokes, with publication disabled: deliberately break a checked property and verify that execution stops before the release step. Testing the diagnostic alone cannot establish that its caller respects failure.

By the September 26 source snapshot, strict mode was the default and both build branches called the checker directly. The snapshot still checked the first numbered sitemap child and an HTTPS canonical prefix. The independent inventory and exact target comparisons above test different properties.

Separate site policy from search requirements

Some checks encode choices about a particular site. For example, noindex asks a search engine to exclude a page from its index. It can be an intentional archive policy, but useful category or index pages need not all be excluded. Choose which pages belong in search, then make the sitemap and page directives agree with that choice.

An accurate lastmod can describe a significant update; inventing a fresh date at every build would defeat that purpose. The May configuration contains no serialize callback implementing the per-page dates the original article described. A missing date is not evidence that Google cannot discover an update.

The Article, Person, WebSite and BreadcrumbList schemas describe the content, author, site and navigation. Structured data should describe the page and meet the guidance for the feature you want. Google's Article documentation does not make Article markup a requirement for Top stories, and its AI-feature guidance calls for no special schema for AI Overviews or AI Mode.

Likewise, a title-length range or exactly one <h1> may be a template convention. Google's title-link guidance favors clear, descriptive titles and explains display truncation; it does not impose a universal 30-to-65-character rule. Label such checks by the policy they enforce.

Keep the search diagnosis open until it is supported

I originally treated the Sitemaps row's "Temporary processing error" in URL Inspection as proof that Google had failed to process sitemap entries and left the articles unindexed. Google's documentation for that field describes a temporary problem retrieving sitemap data for the report. That message does not establish why a URL is absent from the index.

The dashboard showed a 58 percent impressions decline for one page. That figure did not establish the size of a site-wide loss, the contribution of unindexed pages or the effect an individual repair would have. The February-to-May sequence gives me a reason to investigate; it does not isolate the migration's effects.

Retain separate records for the generated files, HTTP responses and later search observations. A served sitemap and correct canonical declaration demonstrate properties you can inspect. Search Console's indexing reports, chosen canonicals and performance measurements answer different questions over time. Google's sitemap guidance treats submission as a hint; it does not guarantee crawling or indexing. A migration report should state which observation changed, without turning a successful build or submission into a claim of recovered traffic.

Make the migration contract explicit

The twelve properties I want the build to check are concrete:

  1. Every intended article appears across the sitemap's child files, with no obsolete or unintended entries.
  2. Sitemap modification dates come from honest source fields and significant changes.
  3. Articles meant for search do not carry noindex.
  4. Archive and index pages follow the explicit policy chosen for that site.
  5. Structured data parses correctly and describes the page.
  6. Each canonical declaration resolves to the intended page and host.
  7. Titles meet the site's editorial conventions and identify the page clearly.
  8. Titles do not repeat the site name.
  9. Articles have useful, nonempty descriptions.
  10. Articles have the intended Open Graph image or a deliberate fallback.
  11. Images have appropriate text alternatives, with decorative images handled deliberately.
  12. Page headings follow the site's chosen document structure.

The advertised sitemap address and chosen www or apex host also have to work when requested. Then the release path has to stop on a failed required check. A script that reports the problem while its caller proceeds cannot enforce the contract.

A static-site migration changes URL structures, sitemap formats, canonical patterns and the pipeline that produces them. Define the outputs you mean to preserve, divide the inspection work, make the severity and design decisions, and enforce the resulting checks at the release boundary. Writing a check can take an evening; an unnoticed regression can remain much longer. I want the next migration to make those expectations executable before the site ships.


Update (2026 May 7): The companion article covers directing an AI assistant across search and hosting tools.