Sitemap Still References Old Domain

After domain migration, sitemap.xml still lists URLs on the old domain. Search Console sees mismatched URLs.

You migrated from old.com to new.com. Set up redirects. Updated Search Console. But you check https://new.com/sitemap.xml and the URLs inside still say <loc>https://old.com/article</loc>. Search Console flags “URLs in sitemap from wrong host.” Even though redirects work, Google’s sitemap parser may discard URLs that don’t match the sitemap’s own hostname — and you’ve effectively published a useless sitemap. Most static site generators bake the site URL into sitemap at build time, so the cause is almost always a stale site config that wasn’t updated during migration.

Common causes

Ordered by hit rate, highest first.

1. Astro site: config still points to old URL

In astro.config.mjs:

export default defineConfig({
  site: 'https://old.com',  // ← bug
});

@astrojs/sitemap reads site to compose URLs. Stale config → stale sitemap.

How to spot it: Open astro.config.mjs and check site value. If old, that’s it.

2. Next.js siteUrl env var still old

next-sitemap.config.js:

module.exports = { siteUrl: process.env.SITE_URL || 'https://old.com' };

If SITE_URL not set in production env, falls back to hardcoded old URL.

How to spot it: Check .env.production or platform env vars for SITE_URL.

3. Hugo baseURL in config.toml not updated

baseURL = "https://old.com"

Hugo bakes this into all generated URLs including sitemap.

4. Custom sitemap script has hardcoded URL

Some sites use a custom build script to generate sitemap with a hardcoded host. Migration forgot to update it.

How to spot it: grep -rn "old.com" scripts/ build/.

5. CDN cached old sitemap

You updated config and redeployed, but CDN is serving the old sitemap.xml from cache.

How to spot it: After deploy, curl yourdomain.com/sitemap.xml?nocache=$(date +%s) to bypass cache. If different from curl yourdomain.com/sitemap.xml, CDN cache.

6. Sitemap split across multiple files, only main updated

Site has sitemap-index.xml referencing sitemap-articles.xml, sitemap-pages.xml, etc. You updated config but only the main sitemap regenerated.

How to spot it: Open each sub-sitemap and check.

Shortest path to fix

Step 1: Find the site URL config

Look in:

  • Astro: astro.config.mjssite:
  • Next.js: next-sitemap.config.js, next.config.js, env vars
  • Hugo: config.toml or hugo.tomlbaseURL
  • SvelteKit: svelte.config.js → adapter config or env
  • Custom: search grep -rn "siteurl\|site_url\|baseurl" .

Find the place where the canonical site URL is set.

Step 2: Update to new URL

Set it to your new canonical URL:

// Astro
site: 'https://new.com',
# Hugo
baseURL = "https://new.com"
# Next.js / .env.production
SITE_URL=https://new.com

Step 3: Rebuild and redeploy

npm run build

Verify locally before deploying: cat dist/sitemap-index.xml | head -20 — URLs should use new domain.

Step 4: Verify on production

curl https://new.com/sitemap.xml | head -20
curl https://new.com/sitemap-articles.xml | head -20  # if split

All URLs should reference new domain. Force CDN purge if you see old.

Step 5: Submit updated sitemap

Search Console → new property → Sitemaps → submit sitemap.xml. If old sitemap is registered, remove the old entry.

Step 6: Add CI assertion

# In CI after build
if grep -q "old.com" dist/sitemap*.xml; then
  echo "ERROR: sitemap still references old domain"
  exit 1
fi

Prevent regression.

When this is not on you

Some sitemap generators are independent of site config (e.g., custom scripts). Audit your entire build pipeline, not just one config file.

Easy to misdiagnose as

People assume the platform “auto-detects” the deploy URL. Most don’t — they bake values from your config file at build time. If the config is stale, sitemap is stale.

Prevention

  • Single source of truth for site URL (config file or env var).
  • CI assertion: sitemap URLs must match the canonical hostname.
  • After any domain change, build locally and inspect sitemap before deploying.
  • Use env variables for site URL in production; don’t hardcode.
  • For multi-sitemap setups, audit every sub-sitemap, not just sitemap-index.xml.

FAQ

  • How long until Google reflects the new sitemap? 1-14 days for processing. Submit explicitly via Search Console to accelerate.
  • Can I have two sitemaps temporarily? Yes — one per language or per section is fine. But all URLs in any sitemap must use the canonical hostname.

Tags: #Domain #DNS #SSL #Troubleshooting #Sitemap #Old domain