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

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.

/Sitemap.xml

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
    <loc>http://www.example.com/assets/cnt/sitemap/main.xml</loc>
   </sitemap>
</sitemapindex>

/assets/cnt/sitemap/main.xml

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://www.example.com/</loc>
        <changefreq>daily</changefreq>
    </url>

    <url>
        <loc>http://www.example.com/Customer-Service</loc>
    </url>
</urlset>

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

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
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? –  w3d Dec 29 '11 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). –  DisgruntledGoat Dec 29 '11 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 Dec 29 '11 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

EDIT:

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.

share|improve this answer
    
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. –  DisgruntledGoat Dec 29 '11 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. –  w3d Dec 29 '11 at 9:12
    
OK sorry. But listing URLs in any folder does work. –  DisgruntledGoat Dec 29 '11 at 12:40
    
Edited question so it uses <sitemapindex>. Thanks. –  RHPT Dec 29 '11 at 14:26

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.