Fixing Sitemap and Robots.txt Drift After a Migration
During a migration, two small files are easy to forget: robots.txt, which tells crawlers what they may fetch, and the XML sitemap, which tells them which pages you want indexed. After launch they often "drift": robots.txt still carries the staging site's block, the sitemap still lists old addresses that now redirect, or the Sitemap line points at the old domain.
None of this breaks the site for visitors, so it can go unnoticed for weeks while crawling slows. This guide shows how to find each kind of drift and put both files right on the new and old hosts.
What drift looks like after launch
"Drift" is the gap between what the two files say and what the new site actually is. It appears because both files are usually generated by the platform, copied from staging, or hand-written once and never revisited. The table lists the patterns that turn up most often after a move.
| Symptom | Typical cause | Effect |
|---|---|---|
Disallow: / on the live site | robots.txt copied from staging, or a platform "discourage search engines" setting left on | Crawlers stop fetching pages; new URLs are not discovered and old ones are not recrawled. |
| Sitemap lists old addresses | A static file carried over, or an export taken before URLs changed | Every listed URL redirects; search engines treat the sitemap as low quality and rely on it less. |
| Sitemap uses the staging host | Base URL set to the staging domain in the generator | Search Console rejects the URLs as not belonging to the property. |
Sitemap: line points at the old domain | robots.txt edited by hand before the move | Crawlers fetch an old file, which may be missing or out of date. |
| Old domain blocks everything | Someone "closed" the old site with Disallow: / | Crawlers cannot fetch old URLs, so they never see the redirects. |
| Sitemap includes noindex or canonicalised pages | Generator lists every published item regardless of settings | Mixed signals; the Page indexing report fills with exclusions. |
The Site Migration Audit's indexing and lost-URL checks often point here first: a sudden drop in crawled pages, or large numbers of "Blocked by robots.txt" and "Page with redirect" statuses, usually trace back to one of these rows.
Staging protection that survives launch
Staging sites are rightly hidden from search engines, but the protection can use several layers, and each one has to be removed separately. Check for all of these on the live site:
- robots.txt. A blanket
Disallow: /underUser-agent: *. - Meta robots. A
<meta name="robots" content="noindex">in the template. In WordPress this comes from the "Discourage search engines from indexing this site" box under Settings, Reading. - HTTP header. An
X-Robots-Tag: noindexheader added in the server or CDN configuration. It is invisible in the page source, so check the response headers. - Password or IP restriction. Basic authentication or an IP allow-list left on some paths, such as the sitemap or media folder.
- Environment variables. Frameworks and hosts often switch robots rules based on an environment flag. If the production build was made with the staging flag, the wrong rules ship.
curl -s https://www.example.co.uk/robots.txt
curl -sI https://www.example.co.uk/ | grep -i "x-robots-tag"
curl -sI https://www.example.co.uk/sitemap.xml | grep -i "^HTTP\|x-robots-tag\|content-type"
Remember that robots.txt and noindex do different jobs. A robots.txt block stops crawling, so a search engine may never fetch the page and therefore never sees a noindex tag on it. If you need a page out of the index, it has to be crawlable so the noindex can be read.
Rebuilding the sitemap for the new site
The sitemap should be a list of the new site's canonical, indexable pages, and nothing else. The safest source is the new platform's own generator, because it updates as pages are published. A one-off export works for small static sites but drifts as soon as content changes.
What every listed URL must be
- An absolute address on the new host with the final scheme, such as
https://www.example.co.uk/. - Returning 200, not a redirect, a 404 or a login page.
- Self-canonical: the page's canonical tag points at the same address.
- Indexable: no noindex in the meta tags or headers, and not blocked by robots.txt.
Size and structure
A single sitemap file may hold up to 50,000 URLs and 50 MB uncompressed. Larger sites use a sitemap index that lists several files. Splitting by section, such as products, categories and articles, also makes the Search Console reports more useful, because you can see which section is being indexed slowly.
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.co.uk/sitemaps/products.xml</loc>
<lastmod>2026-09-26</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.co.uk/sitemaps/articles.xml</loc>
<lastmod>2026-09-27</lastmod>
</sitemap>
</sitemapindex>
lastmod after a migration
Google uses lastmod when it is consistently accurate and ignores priority
and changefreq. A common migration mistake is stamping every page with the launch date,
because the import touched every record. Carry the real last content change across from the old CMS if
you can. If you cannot, leave lastmod out rather than filling it with a date that is not
true.
Platform notes
| Platform | Sitemap | robots.txt |
|---|---|---|
| WordPress | Core serves /wp-sitemap.xml; SEO plugins such as Yoast and Rank
Math replace it with their own index, usually /sitemap_index.xml. Only one should be submitted. | WordPress
generates a virtual file unless a real robots.txt exists in the web root, in which case
the real file wins. Check which one you are editing. |
| Shopify | Generated automatically at /sitemap.xml and cannot be edited directly. | Edited
through the robots.txt.liquid theme template; the default is sensible for most shops. |
| Next.js and other frameworks | The App Router supports a sitemap.ts file that
builds the XML at request or build time; make sure it reads the production base URL. | A robots.ts
file does the same; it often switches rules on an environment variable. |
| Static sites and custom builds | Generated by the build tool or a script; regenerate on every deploy. | A plain file in the web root; include it in the deploy, not only on the server. |
The platform-specific guides for WordPress, Shopify and Next.js cover the settings in more detail outside a migration context.
The fix, step by step
Step 1
Read robots.txt on every host involved
Fetch
/robots.txt from the new live host, the old domain, any www or non-www variant and any subdomain
that serves content such as a shop or blog. Read each one line by line. On the new host look for Disallow: /
or rules blocking whole sections, CSS, JavaScript or image folders. Note the Sitemap: lines.
Compare the file with the one the old site had, so rules that were deliberate are kept.
Step 2
Remove leftover staging blocks
Replace
any blanket disallow with the rules the live site actually needs, then check the other layers of staging
protection. Look for a noindex meta tag in the templates, an X-Robots-Tag header in the
server or CDN configuration, password protection on the sitemap or media paths, and a build made with
a staging environment flag. In WordPress, untick the discourage search engines setting under Settings,
Reading. Confirm each fix with curl, not only a browser.
Step 3
Rebuild the sitemap from the new site
Generate the sitemap from the new platform itself rather than reusing the old file or an
early export, so it lists only new addresses on the live host with https and the chosen www form. Split
large sites into section files under a sitemap index, keeping each file within 50,000 URLs and 50 MB
uncompressed. Carry real lastmod dates across from the old CMS if they exist, and leave
the field out rather than stamping every page with the launch date.
Step 4
Clean the sitemap against live status codes
Crawl the sitemap in list mode with a desktop crawler, or run a short script, and record the status code, canonical and robots directives of every URL. Remove anything that redirects, returns 404 or 410, carries noindex or canonicalises elsewhere. Fix the generator setting that let each type in, such as tag archives, attachment pages or filtered collections, so the same URLs do not reappear on the next build. Repeat until every listed URL returns 200 and is self-canonical.
Step 5
Point robots.txt and Search Console at the new sitemap
Update the Sitemap: line in the new robots.txt to the full address
of the new sitemap or sitemap index. Verify the new property in Google Search Console, submit the sitemap
in the Sitemaps report, and remove old submissions that now fail or point at the staging host. Do the
same in Bing Webmaster Tools. Check that the report shows the sitemap as fetched successfully with a
discovered URL count close to what you expected.
Step 6
Leave the old host crawlable
On the old domain, make sure robots.txt does not block crawling, because search engines must be able to fetch old URLs to see their redirects. Serve robots.txt on the old host with a 200 and permissive rules, or redirect it along with everything else. Remove any sitemap there that lists pages as if they still exist. If you keep a temporary sitemap of old URLs to prompt recrawling of the redirects, label it clearly and remove it after a few weeks.
Step 7
Watch the reports until they settle
For the first few weeks, check the Sitemaps report and the Page indexing report in Search Console, filtered to the new sitemap, at least weekly. Look for growing counts of Blocked by robots.txt, Page with redirect and Excluded by noindex tag among submitted URLs. Rerun the Site Migration Audit to compare indexing against the old crawl. Add a check of robots.txt and the sitemap to every future deploy so the drift cannot return unnoticed.
The old domain: what to leave in place
When a domain changes, the instinct is to shut the old one down. For search engines, the old host still has an important job: every old URL must answer with a redirect for long enough that crawlers revisit it and transfer its signals.
- Do not block the old host in robots.txt. A disallowed URL is not fetched, so its redirect is never seen and the old address can linger in results.
- Keep the old Search Console property. It shows how quickly old URLs are being processed, and it is where the Change of Address tool is used for domain moves.
- Consider a temporary sitemap of old URLs. Listing old addresses, which now redirect, can prompt crawlers to revisit them sooner. It will show redirect warnings in Search Console, which are expected here. Remove it once most old URLs have dropped out of the index.
- Keep the old domain registered. Letting it lapse removes every redirect at once and hands its links to whoever buys it next.
Stopping drift on the next release
Both files are small enough to check automatically. A few lines in the deployment pipeline catch most drift before it reaches search engines.
# fail the deploy if the live robots.txt blocks everything
curl -s https://www.example.co.uk/robots.txt | grep -qx "Disallow: /" && { echo "robots.txt blocks the site"; exit 1; }
# fail if the sitemap mentions the staging host
curl -s https://www.example.co.uk/sitemap.xml | grep -q "staging.example.co.uk" && { echo "staging URLs in sitemap"; exit 1; }
- Keep robots.txt in version control, with separate files for staging and production chosen by the build rather than edited by hand.
- Protect staging with a password rather than relying only on robots.txt, so the robots file can stay identical between environments.
- Schedule a monthly crawl of the sitemap to catch redirects and 404s creeping back in as content changes.
The Robots and Sitemap Guide explains both files in full, beyond the migration case.
1. Should my sitemap list old URLs after a migration?
The main sitemap for the new site should list only new, final addresses that return 200. Listing old URLs there tells search engines you want redirecting pages indexed, which is contradictory. Some teams add a separate, temporary sitemap of old URLs to encourage crawlers to revisit them and pick up the redirects sooner. If you do, keep it apart from the main sitemap, expect redirect warnings for it in Search Console, and remove it once the old URLs have dropped out of the index.
2. Why does Search Console say my sitemap URLs are blocked by robots.txt?
The robots.txt file on the new host has a rule that matches those addresses, often a blanket disallow copied from staging or a rule written for the old URL structure that now matches new paths. Open the robots.txt report in Search Console to see which version Google fetched, and test a few affected URLs with the URL Inspection tool. Correct the rule, wait for Google to refetch the file, which usually happens within a day, then resubmit the sitemap.
3. Can I block the old domain in robots.txt once the new site is live?
No, not while its URLs redirect. Robots.txt stops search engines fetching the old addresses, so they never see the redirects and cannot move the old pages' signals to the new ones. The old URLs may even stay in results, shown without a description. Leave the old host crawlable, with every URL redirecting, for at least as long as you keep the redirects, which Google suggests should be a year or more.
4. How quickly will Google read my new sitemap?
Google usually fetches a newly submitted sitemap fairly soon, and the Sitemaps report in Search Console shows when it was last read and how many URLs were discovered. Reading the sitemap is not the same as crawling or indexing every listed page, which happens gradually and depends on the size of the site and how often it is crawled. Submitting the sitemap again repeatedly does not speed this up, so submit once and watch the reports.
5. Do I need to submit my sitemap to Bing as well?
It is worth doing. Bing Webmaster Tools accepts sitemap submissions and has its own site move tool for domain changes, and Bing results also feed other search products. Bing also reads the Sitemap line in robots.txt, so a correct line there helps any crawler that follows the standard. If the new site supports IndexNow, which Bing and several other engines use, it can notify them of changed URLs directly as well.
6. My WordPress site shows two different sitemaps. Which one should I use?
WordPress has a built-in sitemap at wp-sitemap.xml, and SEO plugins such as Yoast or Rank Math usually disable it and serve their own index, often at sitemap_index.xml. After a migration both can appear if the plugin setting was not carried over. Pick one, normally the plugin's because it respects its noindex settings, make sure the other redirects or is switched off, reference the chosen one in robots.txt and submit only that one in Search Console.
7. Should lastmod be set to the migration date for every page?
No. Google uses lastmod only when it is consistently accurate, and a date that changed on every page at once because of an import tells it nothing useful. It can also lead search engines to trust the field less in future. Carry the real date of each page's last meaningful content change across from the old system if you can. If the true dates are lost, leave lastmod out until pages are genuinely updated, then let the platform record real changes.
The Site Migration Audit compares your pre-migration crawl with the live site, checks indexing and finds lost URLs, so sitemap and robots.txt drift shows up as pages that are blocked, redirected or missing.
Open Migration Audit Fixes โ