|  首頁
說明

WordPress 託管 說明

CDN image indexing and Yoast SEO

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.

  1. Modify the functions.php file by adding this snippet of code to the top of the file, and replacing example.com in both URLs with your own.
    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' );
        
  2. Save the changes.
  3. Go to the Yoast SEO Sitemap settings and regenerate the sitemap.

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.

Next steps

More Info


這篇文章有用嗎?
感謝您提供意見。 若要與客戶服務代表聯絡,請撥打支援中心電話號碼,或使用上方的對話選項。
很高興能幫上忙! 還有什麼可幫您的嗎?
很抱歉有這種情形。 請告訴我們您不了解的部分,或解決方案無法解決您問題的原因。