To ensure images are being indexed properly by Google Search Console when using the Yoast SEO plugin and a CDN, you should add a small snippet of code to the top of the functions.php file. This code will allow Yoast SEO to properly generate the sitemap for your WordPress website.
function wpseo_cdn_filter($uri) {
return str_replace('https://www.example.com', 'https://secureservercdn.net/example.com/', $uri);
}
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );
The sitemap will now use the CDN URL to reference the images. After this change it could take several days for the images to re-index in your Google Search Console.
Article ID: 1265
Created On: Tue, Nov 17, 2020 at 8:00 PM
Last Updated On: Tue, Nov 17, 2020 at 8:00 PM
Online URL: https://www.heartinternet.uk/support/article/cdn-image-indexing-and-yoast-seo.html