Skip to the indexed answers
Digital Marketing Index

usdigitalmarketingindex.com SEO

When should an image sitemap include assets hosted on a separate CDN?

When images that matter are served from a different hostname and might not be found through the pages alone, and when the conditions for listing them can be met. Google’s documentation permits image URLs on another domain in a sitemap, with a condition: “In some cases, the image URL may not be on the same domain as your main site. This is fine, as long as you verify both domains in Search Console” (Google’s image sitemap documentation). It adds a second requirement, that robots.txt must not disallow crawling of content you want indexed. So the decision has two parts. First, is an image sitemap useful for this site at all? Second, if the images sit on a CDN host, are that host’s verification and crawl access in order? An image sitemap listing CDN URLs that crawlers are blocked from fetching accomplishes nothing.

External image URLs in sitemap entries

An image sitemap attaches image entries to the page they appear on. The page URL belongs to the main site. The image URL can be anywhere.

A realistic CDN-hosted example, with placeholder domains:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
  <url>
    <loc>https://www.example.com/products/thermostat-t200/</loc>
    <image:image>
      <image:loc>https://cdn.example-media.net/products/thermostat-t200-front.jpg</image:loc>
    </image:image>
    <image:image>
      <image:loc>https://cdn.example-media.net/products/thermostat-t200-wall-plate.jpg</image:loc>
    </image:image>
  </url>
</urlset>

Points from the documentation:

Point Detail
Structure Image tags sit inside the page's url entry; they can be added to an existing sitemap or kept in a separate one, and the documentation calls either approach "equally fine"
Required tags The image container tag and the image location tag
Limit Up to 1,000 image entries per page entry
Removed tags Caption, geo location, title, and license tags were removed from the documentation; do not add them
Purpose To tell Google about images "we might not otherwise find (such as images your site reaches with JavaScript code)"

When the image sitemap earns its place:

Situation Include images in a sitemap?
Images loaded by JavaScript, galleries, or carousels not present in the served HTML Yes
Images important to the business: products, portfolio, original photography Yes
Images in plain <!–INLINECODE0–> elements on crawlable pages Optional; they can be found through the pages
Decorative images, icons, and interface graphics No
Images on pages that are not indexable No

Hosting on a CDN does not by itself make a sitemap necessary. An image in an ordinary img element is discoverable through its page wherever the file lives. The CDN matters because it adds conditions.

Verification and crawl access

Two things must be true of the CDN hostname.

Verification. The documentation says the arrangement is fine “as long as you verify both domains in Search Console”, and, for a content delivery network, to “make sure that the hosting site is verified in Search Console”.

CDN setup Verification route
A subdomain of your own domain, such as images.example.com, pointed at the CDN Covered by a Domain property for example.com, or verify the subdomain as its own property
A separate domain you own, such as example-media.net Verify that domain
A hostname owned by the CDN provider, shared with other customers You cannot verify a host you do not control; ask the provider about a custom hostname

The first setup is the simplest to manage: a hostname under your own domain, served by the CDN.

Crawl access. The same passage says to “make sure that your robots.txt file doesn’t disallow the crawling of any content you want indexed”. Each hostname has its own robots.txt.

Check On the CDN host
robots.txt exists and loads Fetch it at the root of the CDN hostname
It does not disallow the image paths Read the rules for Googlebot and Googlebot-Image
Images return 200 to a crawler Request with a Googlebot user agent
No hotlink protection blocks crawlers Request without a referrer, and with the main site as referrer
No signed or expiring URLs in the sitemap URLs must be stable
HTTPS Certificates valid

A CDN can be configured with a default robots.txt that blocks everything, or with hotlink rules that refuse requests lacking the site’s referrer. Either makes the images unfetchable, sitemap or no sitemap.

Image inventory coverage

Decide which images to list, and generate the list from data.

Step Detail
Source The CMS or product database, which knows each page's images
Select Content images on indexable pages
One URL per image The canonical, full-size or standard variant, not every resized version
Stable URLs No session tokens, signatures, or cache-busting parameters that change
Match the page Each image listed under the page that displays it
Match the markup The same image URL that appears in the page's HTML
Keep current Regenerated when images are added or removed

The sixth row, on matching the markup, matters most for a CDN. If the page’s HTML references one URL for an image and the sitemap lists a different URL for the same file, for instance a different size or hostname, the two do not corroborate each other. Use one form.

A coverage check:

Measure Compare
Images in the sitemap Against content images found by crawling the pages
Pages with image entries Against indexable pages that have images
Images in the sitemap that return errors Should be none
Images on pages and absent from the sitemap Decide whether they should be listed

Sitemap testing

Test Method Pass condition
Well-formed XML with the image namespace Validate the file Valid
Page URLs Request each 200, indexable, canonical
Image URLs Request each, or a sample 200, image content type
Crawler access to images Fetch with a Googlebot user agent; test against the CDN's robots.txt Allowed
Verification Search Console property list CDN hostname verified or covered
Submission Sitemaps report in Search Console Read successfully; no errors
Agreement with pages Compare sitemap image URLs with <!–INLINECODE2–> values in page HTML Same URLs
Stability Fetch the sitemap on two days Image URLs unchanged for unchanged images
Outcome Performance report with search type set to image, by page Impressions for pages whose images were listed

Read the outcome with care. A sitemap is a way of telling Google about URLs. It does not cause indexing, and an image listed in a sitemap is assessed like any other.

Decision summary:

Condition Action
Important images, on a CDN hostname under your domain, crawlable List them
Important images on a separate domain you own Verify the domain, check its robots.txt, then list them
Images on a provider-owned shared hostname Arrange a custom hostname first
CDN blocks crawlers Fix access first; the sitemap changes nothing until then
All images in plain HTML on crawlable pages, low importance A sitemap is optional
Expiring or signed image URLs Do not list; provide stable URLs

Changing which host serves the images is a migration, with redirects and mapping of old image addresses, and that work is described in the guide to how image URLs can retain search visibility during a media library migration.

The rule: list CDN-hosted images when they matter and might be missed, after confirming the CDN hostname is verified in Search Console and open to crawling.

Link trail

Reader comments on this answer

Add your comment to this answer

Your email address will not be published. Required fields are marked *