After any non-trivial WordPress migration — search-replace on the database, host swap, multisite split, or large content import — the Yoast indexable table goes out of sync with reality. The sitemap shows old URLs, the canonical points at the staging domain, and the SEO score on posts hasn’t recomputed. The Yoast docs say “run the reindex from Tools.” On a 50k-post WordPress site, that times out. The procedure that actually works is mechanical and batched.
What’s happening
Yoast SEO 14+ uses an “indexable” architecture: wp_yoast_indexable is a denormalized cache of every post, page, term, and author with computed canonical URLs, breadcrumb data, and SEO metadata. The indexable is populated incrementally as posts are saved — but bulk operations like wp search-replace, SQL imports, or migrations don’t fire WordPress save hooks, so the indexable goes stale silently. The sitemap reads from the indexable, not from wp_posts, so it serves stale URLs until you rebuild.
How to verify
From WP-CLI on the WordPress host:
wp db query "SELECT COUNT(*) FROM wp_yoast_indexable WHERE object_type='post'"
wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_status='publish' AND post_type IN ('post','page')"
wp db query "SELECT permalink FROM wp_yoast_indexable LIMIT 5"
wp option get home
curl -s https://example.com/sitemap_index.xml | grep -c '<sitemap>'
curl -s https://example.com/post-sitemap.xml | head -10
The indexable count should roughly match the published post + page count. A sample of permalink values should show the current domain, not the old one. If you see staging URLs in wp_yoast_indexable, that’s the broken state.
The fix
-
Run the reindex from WP-CLI, not the dashboard. Dashboard reindex runs through admin-ajax and times out on large sites. WP-CLI:
wp yoast index --reindexOn WordPress sites with 10k+ posts, batch it:
wp yoast index --reindex --batch-size=200The batch size of 200 is conservative — increase to 500 on a beefier host. The command is idempotent — safe to re-run if it stalls.
-
Multisite networks. Reindex each subsite individually:
wp yoast index --reindex --networkOr loop over sites:
wp site list --field=url | while read url; do wp yoast index --reindex --url=$url; done -
Recover from a partial reindex. If the reindex errors out partway, you can have a half-stale indexable. Truncate and rebuild from scratch:
wp db query "TRUNCATE TABLE wp_yoast_indexable" wp db query "TRUNCATE TABLE wp_yoast_indexable_hierarchy" wp yoast index --reindexStack Harbor’s enterprise WordPress migration playbook uses TRUNCATE + reindex as the default post-migration step rather than incremental rebuild — it’s faster and avoids drift.
-
Schema mismatch errors. If
wp yoast indexerrors with column-not-found, the Yoast plugin was upgraded but the schema migration didn’t run. WP-CLI:wp plugin deactivate wordpress-seo && wp plugin activate wordpress-seoThis re-triggers the schema migration. Verify with
wp db query "DESCRIBE wp_yoast_indexable". -
Permalink resolution after the rebuild. Even with a fresh indexable, Yoast caches some computed values. After rebuild, also flush the rewrite rules and clear Yoast’s transient cache:
wp rewrite flush wp transient delete --all -
Validate the sitemap. After rebuild, the sitemap should reflect current content immediately:
curl -s https://example.com/post-sitemap.xml | grep -c '<url>'Compare to
wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_status='publish' AND post_type='post'". They should match. Differences greater than 5% indicate a deeper issue. -
Search Console resubmission. Once the indexable is rebuilt and the sitemap is accurate, resubmit it in Search Console (Sitemaps > Submit). Google will recrawl based on the lastmod values in the sitemap, which Yoast pulls from the indexable.
Stack Harbor runs Yoast indexable rebuilds as part of enterprise WordPress migrations. Start the conversation when your WordPress sitemap still shows old URLs after a migration.