Yoast og:image Not Following CDN? The indexable Cache Bypass
Β· 8 min read
While doing the final verification pass on a CDN migration for a client site, a full crawl of 233 pages turned up 95 files whose og:image still pointed at the pre-migration domain and returned 404 β on the same pages where twitter:image and JSON-LD images were already serving the CDN domain. The rewrite pipeline covered the attachment output path, yet the social card image slipped through alone. This post records the diagnosis and the fix.
TL;DRβ
- Yoast SEO (verified on 28.2) picks
og:imagethroughadd_from_indexable, which consumes theopen_graph_image_metacache string first. The old domain lives inside that cached string and is returned verbatim β the WP attachment API is never touched, so URL rewrites attached to the attachment layer cannot intercept it. - Two-step fix: hook a domain-swap callback on the
wpseo_opengraph_imagefilter (shipped as0.5.0and deployed to both sites), then clear the cache withecho y | wp yoast index --reindex. Verification: all 95 affected files now return 200 (95/95), and a re-crawl of 233 pages shows zero og/twitter old-domain references.