CDN SEO: Indexing Images in SERPs

cdn seo indexing images

SEO plays a very vital role when it comes to the success of your website, and a small part of that includes your images appearing in Google image search correctly. There is sometimes confusion about how a CDN handles images and so in this post we show you the best practices for indexing images in SERPs while using a Content Delivery Network.

Importance of Images in SERPs

From our experience, image search potential is always underestimated. If you don’t setup your CDN properly, your images might not be indexing at all and you could be missing out on a lot of potential traffic from Google image search. Just how much traffic are talking about? Let’s take a look at some of the data.

  • According to a case study by Brafton Marketing, 63% of Google image search clicks turn into site traffic. Obviously this will vary from niche to niche, but that is a lot.
  • Chris Pearson did an analysis of his images searches vs total searches going back five years. He discovered that over a 5 month period over 53% of his total searches came in the form of image searches.
google image searches

Google Image Searches vs Total Searches

So let’s say your images are clicked on 500 times in Google image search over the period of a month and you sell a product with a conversion value of $50.00. If 63% of that image traffic converts to site traffic, and a mere 3% of that converts into a customer, that is potentially an additional $472.50 in sales simply from indexing your images correctly.

Easy Win

Now of course the quality of image traffic will always vary depending upon the topic of the site, and might not always convert. For example, a blog about finance where they also sell services might have a harder time converting image traffic than an eCommerce website where people are searching for pictures of specific furniture and are ready to buy.

Either way still think of Google image search as an easy win. Partially because there’s less competition and also because the competition is less likely to be properly optimized. Also, as long as you SEO your images properly and index them, there really is no extra work involved.

Ways to Track Google Image Search Traffic

You can track your google image search traffic by looking at your referral traffic in Google Analytics and looking at the search analytics in Google Search Console. Follow the steps below:

Google Analytics

Note: by default it seems Google Analytics doesn’t always pass the correct referrer, and so it is recommended to set up additional filters to see a more accurate data.

  1. In Google Analytics click into “Referrals” under “Acquisition.”
    Google Analytics acquisition referrals
  2. Search for “Google” and you will most likely get the different international versions of Google that come up. In our example, we will be using the U.S. one so click into “”
    google referrer
  3. Click into the referral path of /imgres
    google imgres
  4. Add “Landing Pages” as a secondary dimension. And you will now see which pages are getting click into from SERPs. It’s not perfect as you can’t narrow down exact images (unless the page only has one image), but it helps to know which pages are getting traffic from Google Image Search.
    google image search referrals

Google Search Console – Search Analytics

You can also view image search traffic, clicks, and positions in Google Search Console. The one downfall to this is that they only provide data for the last 90 days.

  1. In Google Search Console click into “Search Traffic” and then “Search Analytics.”
  2. Change the search type to “Image.”
  3. You can then also enable impressions, CTR, and positions.
google search console images

Click to view larger

Checking The Index Status of Your Images

You can check if your images are indexed by looking at the sitemap data in Google Search Console or by using the site search operator in Google.

Google Search Console – Sitemap

In this example we are using WordPress and the Yoast SEO plugin to submit our sitemaps. Sitemaps aren’t necessarily required if your website is setup properly, but by using them it can help you diagnosis problems with your site and dig deeper into the data.

  1. In Google Search Console click into “Crawl” and then “Sitemaps.”
  2. Then click into your “Images” tab and you can see the number of images indexed out of the total submitted, within each of your sitemaps.
google search console image sitemap

Click to view larger

Google Site Search Operator

If you aren’t using sitemaps, you can also quickly jump over to Google and use a quick site search operator to find and view the images that are indexed.

To find images on your domain simply type in and click into “Images.” You will then see all the images that are indexed. If you are checking images on a CDN you would want to type your zone URL or if you are using a custom URL, your zonealias. But instead of using the site parameter you change to the URL parameter.

KeyCDN Zone URL Example:
KeyCDN Zonealias Example:

Proper Image Indexing CDN Configuration

When it comes to setting up your CDN for indexing images there are a couple things you want to keep in mind, such as your if you are going to use your default zone URL or custom URL (CNAME), enabling the canonical header, and your robots.txt. file.

Zone URL vs Custom URL

You have two choices when setting up your CDN. By default when you setup a zone with a CDN provider your assets will point to their default zone URL such as Setting up a custom URL with a CNAME allows you to point your assets to a subdomain on your own domain such as

You can properly index your images using both methods, but a custom URL has some advantages.

  1. If you use the custom URL you can use the sitemap method to view the indexed images data as we mentioned earlier. If you use the default zone URL, you will not be able to view this data. You could still use the URL search operator.
  2. You have full control over it and can switch CDN providers more easily while retaining the same URLs.
  3. The domain name will contain keywords relevant to your site. This can make for better branding, as people will your image URLs.

And remember, serving your images from a CDN to Google image search will always be faster than serving them from your origin server, due to having multiple POPs around the globe.


An extra HTTP header added to your zone lets the Google crawler know that the content from the CDN is a copy. Once we add rel="canonical" to the HTTP header, your images will index normally as the crawler will know that they are only a copy and not duplicate content.

canonical tag

HTTP header with rel=”canonical”

You can enable the canonical header in the KeyCDN dashboard and it will be applied to the entire zone.

canonical header keycdn dashboard

Canonical Header – KeyCDN dashboard

Robots.txt File

Search engines check for a robots.txt file at the root of a site. If the file is present, they will follow the instructions but if no file is present, they will scan everything. We will not enable the file by default, meaning that everything will be indexed.

Here’s the robots.txt file that we will add to your site if you enable the Robots feature in the dashboard:

User-agent: *   
Disallow: /
  1. The first line defines the crawler the rule applies to. In the example above, the robots.txt applies to every crawler. "User-agent: Google" would only apply for Google bots.
  2. The next line defines what path can be indexed. "Disallow: /" tells the search engine to not index anything.

You can still create your own robots.txt with more detailed instructions. Robots.txt can also be enabled in the KeyCDN dashboard.

robots file

Robots file – KeyCDN dashboard

Yoast SEO and CDN Indexing

If you are using WordPress and your CDN images start to get de-indexed from your Google Search Console account, this is likely a sitemap structure issue. Assuming you are using the Yoast SEO WordPress plugin, you may need to add the following snippet at the top of your functions.php file in order for Yoast to index your images from the CDN domain. Update the domain and your CDN URLs accordingly in the snippet below.

function wpseo_cdn_filter( $uri ) {
return str_replace( '', '', $uri );
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );

After adding this it might take a few days for your images to re-index in Google and show up in Google Search Console.

SEO Your Images

Now that you have learned a couple ways to configure your CDN for indexing images, there are also a few SEO tips that you always want to apply.

  1. Apply a source attribute specifying the URL of the image.
    <img src="">
  2. Apply a width declaration (E.g. width="200px")
  3. Apply a height declaration (E.g. height="200px")
  4. Add an alt attribute to describe the image—this is the most important part of image SEO. (E.g. A picture of a blue car would have an alt tag of alt="blue car").
  5. Always use hyphens when naming your images. Google sees underscores as one word. This can seriously affect your image rankings. (E.g. blue-car.png)
  6. Optimize your images with lossless compression so they load faster no matter where they are, your website or Google image search.


As can you can see, it is important to know how a CDN handles images so that when your dealing with Google and SEO you can make the appropriate changes and configuration so that you don’t lose any traffic. This could be choosing between a default zone URL or custom URL, adding canonical tags, or using the robots.txt file. And by loading your images on a CDN, besides still being indexed properly, they will also load faster, and Google loves speed.

If you have any questions regarding images and indexing them on a CDN, feel free to comment below!

Related Articles

CDN SEO: Indexing Images in SERPs was last modified: June 6th, 2017 by Brian Jackson
  • Anand


    Thanks for the Nice Post, But i have a query regarding one of my project images URLs. My domain is but the images pattern url are is it good from SEO point of view or not.

    Waiting for your reply.

  • Only 2% of my CDN images were indexed due to Yoast SEO. I hope the above functions.php snippet helps.

    • Hey Rick, yes the above snippet will fix your image indexing issues. Give it a couple days though after implementing. Unfortunately GSC is slow to update.

  • Anand

    In my website image URL pattern is “” is it good from SEO point of view because it does not contain my website URL and How image will generate traffic to my website. Please explain

  • Anthony Barré

    Hi Brian,

    Could you elaborate why you suggest to use a rel=canonical link for images search on the CDN domain? This header is only for web search. It was mentioned in this page

    “Google currently supports these link header elements for Web Search only. ”

    I wonder if in this case, the sitemap must contain the links to the canonical urls.

  • Hi Anthony,

    Google says here:

    “Generally, the best practice is to have only one copy of any type of content. If you’re duplicating your images across multiple hostnames, our algorithms may pick one copy as the canonical copy of the image, which may not be your preferred version. This can also lead to slower crawling and indexing of your images.”

    That’s why it’s best practice to use the canonical header when having images on multiple hostnames. This should not affect the functionality of your sitemap as the canonical link points to the appropriate hostname for which the images should be indexed under.

  • Floria Alex

    Does it mean that images will de-index from main domain in Google webmaster tools and then will re-index from custom domain? Because Yoast SEO will create image sitemaps only for custom domian and of course all image paths will be overwrite by custom domain URL.

    What if we still want to index images from main domain? and use custom domain just for CDN. It makes sense that using canonical URLs will resolve duplicate content issues as google will still index images from custom domain but real question is about not losing your image rankings which is associated with main domain URLs.

    • Hi Floria,
      Your images will continue to be indexed on your main domain in Google webmaster tools. The Yoast snippet is simply to tell Google that the image being loaded is from the CDN URL however these will still be indexed properly under the main domain.

      • Floria Alex

        But isn’t it that the code will change image URLs from sitemap? If yes, then Google won’t get image sitemap of main domain. Or will it generate a separate sitemap for custom domain?

  • Hepsu

    This is still something that most people have trouble to understand, and frankly – so do I.

    Let’s say that I have site with Yoast installed, and I want to use CDN.

    Yoast should add canonical headers by default (right?).
    So I don’t need to activate the ‘add canonical’ in your dashboard, correct?
    If I would activate it, while having Yoast in use, would that be harmful?

    If I enable the robots.txt and deny all robots will I still run into trouble? Will my images start to de-index?

    So even after taking these two steps, do I still need to put that piece of code to my functions.php???

    • Yoast doesn’t add the canonical URLs by default to your static assets that is why you need to enable the canonical option in your KeyCDN zone.

      Why would you want to deny all robots? That means that the robots won’t be able to crawl your website content which isn’t recommend.

      The functions.php snippet that you need to add is to fix the Yoast XML sitemap so that the asset URLs are properly pointing to your CDN URL instead of your origin URL. This is required since once you’ve integrated a CDN into your website all of your static asset URLs will be using your new CDN URL and the sitemap needs to reflect that as well.

      • Hepsu

        Hi Cody,
        Thanks for answering. I hope you can clarify this further.

        1. Yoast adds canonicals to most pages (, but is it necessary for all inidividual images as well?

        2. I didn’t mean that I would add disallow all robots.txt to my origin server.
        If I activate this function on KeyCDN dashboard, doesn’t that mean that robots are forbidden only from crawling my CDN files?

        3. As you already answered: “The functions.php snippet that you need to add is to fix the Yoast XML
        sitemap so that the asset URLs are properly pointing to your CDN URL
        instead of your origin URL. This is required since once you’ve
        integrated a CDN into your website all of your static asset URLs will be
        using your new CDN URL and the sitemap needs to reflect that as well.”

        Should I just forget the robots.txt and hope that adding canonicals is all I need to keep my images on Google?

        • 1. Yoast add the header to pages, but KeyCDN adds rel=”canonical” to each static asset to let the search engines know where the original file comes from.

          2. If you enable the robots.txt option it will by default disallow everything. However, you can configure your own custom settings if you wish. Most times leaving this as disabled works fine

          3. Correct, just add the functions.php snippet if you are using yoast and enable the canonical option in your zone.

          • Hepsu

            Hi Cody,
            One more question popped into my head. I’ve now done some testing with your CDN and seen some growth in indexed images. However, Yoast doesn’t create sitemap for images as a default setting, so if I don’t use seperate sitemap for images, do I really need that filter in my functions.php?

          • Yes you should still use it to tell the crawlers where your images are coming from within the sitemap once you start using the CDN URL. Yoast also outlines this

          • Hepsu

            I noticed that the filter changes image paths ONLY for featured images. How can I force the rest of the post images to change as well?

          • Hepsu

            Hi Cody,
            I managed to solve the problem. I can’t be the only one who has/had this issue, so I’m linking my solution here:
            This could really benefit your users.

  • Hi, I have a question to Yoast SEO and CDN indexing. I use multiple subdomains for my cdn (cdn, cdn2, cdn3, cdn4). How would I use your custom code for the function.php to correctly implement all 4 subdomains? Thanks for your help and your awesome article.

  • notabot

    Does using KeyCDN’s zonereferrer hotlink protection impact image SEO? Or does that prevent indexing?

    • Sebastian

      We do not explicitly whitelist search engine crawlers from this but they should behave just like normal browser sessions (Googlebot does) and be able to handle this.
      But if you want to be absolutely sure, you probably should leave “allow empty referrers” enabled.

      • notabot

        Ok, thanks!

  • The URL path itself for images shouldn’t make a difference to crawlers. As long as they can find your images, you should be fine.

  • Hi, I have Question, how about if I use JetPack for Generating Sitemap? Thank You ^_^

  • Hi, Google Search Console was previously saying 147 images submitted / 12 indexed. Now a couple of weeks after following the above, it is saying 147 images submitted and says nothing for indexed?

    • Did you add another property for your CDN domain as well as add the Yoast code?

      • Hi Cody, I added the above code to our functions.php file (with our domain and CDN domain replacing the placeholder values).

        • Did you check your sitemap to ensure that the URLs have been rewritten to the CDN URL? If they aren’t rewritten, disable then re-enable the Sitemap feature in Yoast.

          • Hi Cody, thanks for the response. I have checked the Yoast sitemap, and the URL’s are for the website, not the CDN.

            Could this have anything to do with a Yoast setting or the way KeyCDN has been set up? We are using the CDN Enabler plugin.

          • You will need to disable and re-enable XML sitemap functionality.

          • Thanks for the response, I just tried doing this via Yoast, still showing the website URL in the XML sitemap though.

  • mehedi hasan

    nice writing

Share This