After you push a staging site to production, Yoast SEO can keep the staging domain as the canonical URL — or drop the canonical entirely. The fix is to rebuild Yoast’s indexables so it regenerates every canonical against your live domain, and to set the canonical manually for any single page that is still wrong.
Why are Yoast canonical URLs wrong after a site migration?
Yoast SEO does not calculate canonical URLs on every page load. It stores them in its indexables — a cache of SEO data kept in the wp_yoast_indexable database table, plus per-post values in wp_postmeta. When you push a staging site to your production site, those rows travel with the database.
If the indexables were built while the site still used the staging domain, they hold staging URLs. After the push you see one of two symptoms:
- The
rel="canonical"tag points at the staging URL (for examplehttps://staging.example.com/page/instead ofhttps://example.com/page/). - The canonical tag is missing for some pages, because the stored indexable row is stale or incomplete.
The cause is the cached indexable data, not a broken Yoast install. Yoast emits a self-referencing canonical for every public post and page automatically — there is no global on/off switch to flip. So the goal is to make Yoast rebuild that cache against the correct domain.
How do I fix a single page’s canonical URL in Yoast SEO?
If only one or a few pages are affected, override the canonical directly in the editor:
- Open the affected page or post in the WordPress editor.
- In the Yoast SEO sidebar (or the Yoast meta box below the content), open the Advanced tab.
- Find the Canonical URL field.
- Enter the correct live URL — or clear the field to let Yoast fall back to its default self-referencing canonical against your live domain.
- Update the page.
Leaving the field empty is usually the right choice: a self-referencing canonical is what most pages should have. Only enter an explicit URL when the page should point at a different canonical (for example a syndicated or duplicated page).
How do I bulk-fix canonical URLs after a full-site migration?
When many pages carry the staging domain, fixing them one by one is impractical. Rebuild every indexable at once instead.
Option 1: Reset and re-optimize Yoast’s SEO data
- Install and activate the Yoast Test Helper plugin.
- Go to Tools → Yoast Test.
- Click Reset Indexables & Migrations. This clears the cached indexables so Yoast rebuilds them from scratch.
- Go to SEO → Tools and click Start SEO data optimization. Yoast regenerates every indexable — including canonical URLs — against your current (live) domain.
- Deactivate the Yoast Test Helper plugin once the optimization finishes; it is a developer tool, not meant to stay active.
Option 2: Rebuild indexables with WP-CLI
If you have shell access, the same rebuild runs from the command line:
wp yoast index
This reindexes all of Yoast’s indexables for the current site. It is faster than the browser-based optimizer on large sites and safe to re-run.
After either option, clear every cache — your caching plugin, server cache, and CDN — so visitors and crawlers receive the corrected canonical tags rather than a cached copy of the old ones.
One more thing to check: confirm a search-and-replace ran on the database during the push, swapping the staging domain for the live domain. WP STAGING does this automatically when you push, but if you imported the database another way, a leftover staging domain in the data is the root cause that rebuilding indexables alone will not fix.
How do I prevent canonical URL problems on the next push?
- Let WP STAGING handle the domain rewrite. When you push with WP STAGING, it runs a search-and-replace across the database, including Yoast’s data. Avoid manual database imports that skip this step.
- Rebuild indexables after every push. Make "Reset Indexables & Migrations + SEO data optimization" (or
wp yoast index) part of your post-push checklist. - Never hardcode a per-page canonical to the staging domain. If you set an explicit canonical while testing on staging, clear it before pushing so the live page falls back to a self-referencing canonical.
For background on why canonical tags matter, see Google’s guidance on consolidating duplicate URLs and Yoast’s explanation of rel="canonical".
Frequently asked questions
Will resetting Yoast indexables delete my SEO settings?
No. Resetting indexables clears only the cached SEO data. Yoast rebuilds it from your existing posts and settings, so your titles, meta descriptions, focus keywords, and configuration stay intact.
Why is my canonical URL empty after a migration?
A missing canonical almost always means the page’s indexable row is stale or was not regenerated against the new domain. Rebuilding indexables (Option 1 or 2 above) restores the self-referencing canonical.
Do I need the Yoast Test Helper plugin to fix this?
It is the easiest way to reset indexables and migrations from the WordPress admin. If you prefer the command line, wp yoast index does the rebuild without any extra plugin. Either way, the goal is the same: force Yoast to regenerate its cached SEO data.
Does this apply to both Yoast SEO Free and Premium?
Yes. Indexables exist in both the free and Premium versions of Yoast SEO, so the same reset-and-rebuild process fixes canonical URLs in either one.