If I have a sitemap index, can the sitemaps listed in the index be located in a subdirectory, but have links that isn't specific to the subdirectory? I'm trying to avoid having multiple sitemaps in the root directory of my server, if I can help it.


<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">


<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">


I posted a similar question earlier, but I did not explain myself clearly.

2 Answers 2


According to the "spec" that w3d mentions, sitemap files cannot reference URLs in alternate directories.

However, this is simply not true for all the search engines. I have put sitemap files in a subdirectory and never had a single error in Google or Bing Webmaster Tools.

So in practice it makes no difference where you put sitemaps.

  • 1
    Ha, yes it would seem! (Returns from having looked at ones own sites.) I have indeed done the same (sitemap in an isolated subdirectory), without error and the URLs are indexed. However, I have also referenced the Sitemap.xml file in robots.txt (which obviously resides in the root) - maybe this proves ownership? Since using robots.txt is also a recognised way to get around the "same domain" restriction. Are you also using robots.txt?
    – MrWhite
    Commented Dec 29, 2011 at 15:03
  • I am now but I don't think I was when I first used multiple sitemaps (the robots.txt option wasn't available when I started working with sitemaps). Commented Dec 29, 2011 at 18:31
  • Should have looked at this answer before I deployed the sitemaps to the production root earlier today. Might adjust at a later date.
    – RHPT
    Commented Dec 29, 2011 at 22:35

Although the sitemap index file can list sitemaps in a different directory, the sitemap files themselves cannot reference URLs that are outside of the directory tree/subdirectory in which they are located - which I believe is what you are asking in the second part of your question. So, no, in answer to your overhaul question, I don't think you can. EDIT: At least according to the sitemap spec.

The only criteria with referencing sitemap files from the index is that the sitemap files are on the same domain. (By the way, the sitemap index file should have <sitemapindex> as its root element, not <urlset> as in your "Sitemap.xml" example - these are for ordinary sitemap files.)

Note: A Sitemap index file can only specify Sitemaps that are found on the same site as the Sitemap index file. For example, http://www.yoursite.com/sitemap_index.xml can include Sitemaps on http://www.yoursite.com but not on http://www.example.com or http://yourhost.yoursite.com.

Ref: Using Sitemap index files (to group multiple sitemap files)

However, according to the sitemap protocol, the sitemap files themselves cannot reference URLs in a parent directory, or a directory outside of the subdirectory (as I think you are implying in the 2nd part of your question), as it is deemed that the creator of the sitemap in one location might not have permission to access URLs in an entirely different subdirectory.

The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/.

Ref: Sitemap file location


This is my interpretation of the official sitemap protocol specification. However, implementation would seem to suggest otherwise - see @DisgruntledGoat's answer, but also take note of comments regarding robots.txt.

  • I edited the first sentence as you contradicted yourself by saying "no you can't" then proceeded by saying you can :) Also, sitemap files can reference ANY URL on the same domain with no problems whatsoever. Commented Dec 29, 2011 at 3:40
  • @DisgruntledGoat: But my answer is "No you can't" - in answering the overhaul question - the question in the title is not the complete question. I then answer each part and explain why the answer is ultimately "no". 1. "can the sitemaps listed in the index be located in a subdirectory?" Yes 2. "...but have links [in the sitemap file] that isn't specific to the subdirectory?" No. This is according to the sitemap protocol spec that I link to (and now quoted). So, my overhaul answer is "no", not "yes"?! - I have attempted to clarify my answer.
    – MrWhite
    Commented Dec 29, 2011 at 9:12
  • OK sorry. But listing URLs in any folder does work. Commented Dec 29, 2011 at 12:40
  • Edited question so it uses <sitemapindex>. Thanks.
    – RHPT
    Commented Dec 29, 2011 at 14:26

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.