Skip to main content

One post tagged with "Yoast"

View all tags

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​

  1. Yoast SEO (verified on 28.2) picks og:image through add_from_indexable, which consumes the open_graph_image_meta cache 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.
  2. Two-step fix: hook a domain-swap callback on the wpseo_opengraph_image filter (shipped as 0.5.0 and deployed to both sites), then clear the cache with echo 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.