2

In the screenshot of Google Search Console below, I am looking at my property at example.com/my-site.

The black scribble is my site at example.com/my-site, and the yellow is me attempting to link my sitemap at cdn-site.example/id/sitemap.xml. Linking this sitemap through a shared example.com/robots.txt has not worked, probably because there is a relatively unrelated site at example.com.

Is it possible to "Add a new sitemap" with an external file, is there anything I'm missing here?

If not, can I set my sitemap to .../my-site/sitemap.xml in GSC and place a redirect (301) there to my CDN sitemap? Or will Googlebot be upset about the 301?

enter image description here

2
  • Could you host your full sitemap at /my-site/sitemap.xml? External sitemaps are supposedly supported, but I've never seen anybody actually get them to work. Feb 1, 2022 at 8:40
  • In my team the process for doing that is long, a redirect or GSC-centered fix would be much faster and more straightforward. And updating the sitemap build script to write to a local assets folder would also be complicated. –
    – James L.
    Feb 1, 2022 at 18:21

2 Answers 2

2

I had a similar issue:

  • My website is: mywebsite.example.com
  • My sitemap and sitemap index files are generated and uploaded every night on cdn.example.com/sitemap

I couldn't add my sitemap index file cdn.example.com/sitemap/sitemap.xml in the Google Search Console tool.

So I added this in my website Nginx configuration:

# Nginx configuration for mywebsite.example.com
location /sitemap.xml {
    set $backend https://cdn.example.com/sitemap/sitemap.xml;
    proxy_pass $backend;
    proxy_ssl_server_name on;
}

To get my sitemap index file accessible on mywebsite.example.com/sitemap.xml. I didn't redirect the sitemap files (because I want to keep it simple and don't use rewrite rules if I can), so only my sitemap index is accessible on my website domain. My sitemap index file looks like this:

<!-- mywebsite.example.com/sitemap.xml -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://cdn.example.com/sitemap/sitemap-item-1.xml</loc>
        <lastmod>2022-02-24</lastmod>
    </sitemap>
    <!-- ... -->
</sitemapindex>

It seems to work in the Search Console: my URLs were discovered. But I don't see the sitemap files in the UI, probably because of the different domain. I sent a comment to Google with a screenshot, I'll post an update if I get a response.

Google Search Console - sitemap index with sitemaps on another domain


TLDR: If you use a sitemap index file, it seems that you don't need to add your sitemap files in your website domain, only the sitemap index file.


Edit 2023-04-04 This does not work anymore, I have an error now in the search console.

Now the documentation says:

Your sitemap includes some URLs that are at a higher level or different domain than the sitemap file.

Different domain: Check that the URLs all begin with the same domain as your sitemap location.

1

I created a server side redirect (301 I believe) at /my-site/sitemap.xml to cdn-site.example/id/sitemap.xml. Worked great!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.