• Resolved Klark0

    (@klark0)


    Using the latest versions of WordPress and the W3 Total Cache plugin along with WordPress SEO 1.2.3

    I have the Self-hosted CDN option enabled in W3TC and i’m serving images from cdn.domain.com

    My problem is that the sitemap showing the images from https://www.domain.com rather than cdn.domain.com.

    I’ve searched and I found the API docs for the plugin, along with this wpseo_xml_sitemap_img_src (string)
    Allows you to change the URL for images embedded in the XML sitemap. Most common usecase is to make sure the CDN URL is embedded.

    I’m not sure what code I need to put in my functions to fix this.

    https://www.ads-software.com/extend/plugins/wordpress-seo/

Viewing 10 replies - 1 through 10 (of 10 total)
  • I have the same issue, but with using CloudFront CDN (with a CNAME subdomain).

    A week or so ago I saw google de-indexing my site’s images in webmaster tools. Many of these images were named for better seo. At the same time the images were de-indexed I saw a big drop in traffic and rankings.

    Of course, this may be a coincidence, but the site map for pages points to the origin image location, which is still valid, however when google indexes the web page all the images are pointing to a different URL (the sub domain for the CDN). I am wondering if there has been another google update and this mismatch has raised a flag in google that’s given me a SERP penalty…. Which of course would be ironic if this is the case, given that this is an excellent SEO plugin.

    I thought of using Yoast’s API to set all image locations to one of my distribution servers, but that would still cause a delta between the sitemap and page image locations as Total Cache spreads the image path across a number of distribution server CNAMES. There doesn’t appear to be an API in W3C Total Cache to get the image path it used and then inform Yoast’s SEO plug-in.

    Anyone else noticed an impact recently in their SERPS when there is a difference reported in the sitemap to what is actually on the webpage?

    Not sure if it is the answer you are looking for, but I found that Google very much likes images to be served from the same domain as the HTML, particularly for Google News.

    It is easy to fix; just set W3TC to not use the CDN when serving requests to Googlebot. I guess this could make Google perceive a site as being slightly slower, but I’m willing to live with that.

    Thanks. I will give that a try and see if SERPS bounce back.

    A radically different approach would be to replace CDN providers and go with CloudFlare instead of Amazon (for images at least). Since it works as a distributed proxy between your origin server(s) and clients machines, not by moving files from slow to fast servers as done by standard CDNs, your URLs don’t change. That’s specially useful if you use HTTPS, as in that case Amazon doesn’t support using CNAMEs and you’re stuck with their https://something.cloudfront.net/something URLs.

    On the other hand, CloudFlare doesn’t support video, and it doesn’t have the same end points Amazon has. So, if you need video and/or to get maximum speed in a region without a nearby CloudFlare data center (but with an Amazon one), Amazon is surely the way to go.

    Thread Starter Klark0

    (@klark0)

    @guitargav,

    My images were also de-indexed. I eventually got some example code from yoast, and now my images are back in the index. WebmasterTools is now detecting them as well, so there’s no problem for Google with having your images on a subdomain of your main domain.

    Here’s the code:

    function wpseo_cdn_filter( $uri ) {
    	return str_replace( 'https://example.com', 'https://cdn.example.com', $uri );
    }
    add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );
    Plugin Contributor Joost de Valk

    (@joostdevalk)

    Thanks for sharing that code here Klark0, might be wise to link to the WordPress SEO API docs too ??

    @klark0 and @yoast.

    Thanks for the code snippet. Will implement it now.

    I have 10 CDN subdomains (i.e. media1.domain.com through to media10.domain.com) so there will still be a mismatch between what the site map reports and the subdomain the <img> tag refers to on the page. We shall see how it goes with Google (and I can always dial down the number of sub-domains).

    @alexander
    Not wanting to turn this into a CDN debate, but I did look at CloudFare. It looked too good to be true. However, didn’t like this in their terms where CloudFare reserves the write to update your content to “Add tracking codes or affiliate codes to links that do not previously have tracking or affiliate codes”.

    Thanks for all the help.

    Well, I guess that’s there because they offer optional “apps”, usually JavaScript-based, one can enable or disable at will for each domain, among which tracking (Google Analytics and others), plus 3rd-party apps that might or not add tracking on their own out of their control, so, most probably a catch-all to avoid problems. But now and then I look at the code in pages served by then, and I never see anything in there I haven’t myself explicitly enabled.

    Plugin Contributor Joost de Valk

    (@joostdevalk)

    Could you guys open a new thread for this? Thanks ??

    hi guy’s having the same issues as GuitarGav

    where do i add the code (do i still need to add the code in current version)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] CDN Images in Sitemap’ is closed to new replies.