Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How do I prevent my XML sitemap files from showing up in Google search results like this result of a site: search query:

sitemap in search results

I don't understand why Google would choose to show sitemap files in search results to begin with. These files are not meant for human consumption.

Google needs to be able to crawl it to be able to process it, so I can't disallow it in robots.txt. I just don't want them to put it into the search results after processing it.

share|improve this question
    
Huh. Interesting. The only thought I have is if you have a link to it on your site, or it appears in your sitemap file. As well, I am not sure if you refer to it in your robots.txt file if that may be a factor. I would not think so, just something to consider. I supply my sitemap only through Google WMT only and have not seen this issue- at least not yet. I can understand not wanting your sitemap public. I do not want mine public. Too many hackers/scrapers out there. –  closetnoc May 20 at 16:32
1  
On this particular site I have /sitemap.xml listed in robots.txt and then that links to a different set of other sitemaps like /sitemap-123.xml and /sitemap-124.xml. I regenerate the sitemaps every day and the numbers change daily. The one that is indexed is a fairly old one. I don't link to it anywhere on my site, but it is possible that some other site has a link to it somewhere. –  Stephen Ostermiller May 20 at 16:59
    
If it is not used, make sure it is deleted, then exclude it in your robots.txt file and it will drop from the SERPs fairly quickly. Oddly, the remove URL thing in Google WMT takes forever (months for me) while robots.txt is fairly quick. –  closetnoc May 20 at 17:02
    
Did you submit the XML sitemap to your GWMT account? –  Oleg May 20 at 18:44
1  
The sitemap file still existed until today. I removed it and now it redirects to /sitemap.xml I assume that this particular sitemap will now fall out of the index. I'd like to prevent Google from showing them to search users in the future too. –  Stephen Ostermiller May 20 at 22:47
show 3 more comments

4 Answers 4

up vote 5 down vote accepted

Google does appear to index XML sitemaps (like any XML file). It seems that if Google is aware of a URL and it returns a valid response then it's likely to get indexed. Personally, I only submit the sitemap through GWT and include a Sitemap: reference in robots.txt and this is certainly enough to get it indexed.

I believe the recommended method to prevent these files from being indexed is to include an X-Robots-Tag HTTP response header when serving the XML sitemap. For example:

X-Robots-Tag: noindex

Just like including a robots META tag in HTML files, the X-Robots-Tag header can be used for any type of file.

Reference: This document (from Nov 2008!) appears to quote our very own John Mueller (Google) with regards to the use of the X-Robots-Tag response when dealing with XML sitemaps.
Yes, Google Will Index & Rank Your XML Sitemap File

share|improve this answer
add comment

w3d's answer about using X-Robots-Tag appears to be the correct way to do this. Here is code that can be used in .htaccess or Apache configuration files to do so:

<Files ~ "sitemap.*\.xml(\.gz)?$">
  Header append X-Robots-Tag "noindex"
</Files>

Reference: WebmasterWorld - Sitemaps showing up in SERP - How to prevent this?

share|improve this answer
add comment

put the following into the robots.txt

User-agent: *
Disallow: /sitemap.xml

instead submit your sitemap through google webmaster tools.

share|improve this answer
    
Can you please clarify your logic - your first sentence appears to conflict with your last? –  w3d May 21 at 8:47
2  
Will Google still crawl a sitemap that is blocked in robots.txt? Do you have a reference to support the assersion? –  Stephen Ostermiller May 21 at 8:48
add comment

Why does it matter?

If you can actually find your sitemap in SERP then you have bigger problems.

I would focus more on getting pages up with useful content instead. That way, you will have a very hard time even finding you sitemap. Not that you would care at that point anyway.

P.S.

Pretty much every one keeps sitemaps in the same place. So if someone wanted to find where you keep it they will :)

share|improve this answer
    
I use Google for site search and I stumbled across a sitemap when using it. It would be very confusing for my users if they were to click on it. –  Stephen Ostermiller May 22 at 19:25
    
How many of your users do you think use Google for site search? –  dasickle May 22 at 19:35
    
All the users that type in search terms into the search box at the top of my pages. –  Stephen Ostermiller May 22 at 19:40
    
In that case. Have you considered using something like swiftype.com for your site search? There are a top of others you can use. You can re-order, remove and add results. You also get great stats and etc. –  dasickle May 22 at 19:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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