3

Is there a way to specify the location of generated sitemap files using the lastest version of the Google Sitemap Generator?

Version is: 1.0.0.0? (a very un-google version number, lol):

> sudo /usr/local/google-sitemap-generator/bin/sitemap-daemon -v
Google Sitemap Generator (Beta) Version [1.0.0.0]

The dashboard has a option of "Sitemap file name" but there is no option to specify the destination directory? It always places the generated sitemap XML files in the document root. I assume it discovers the document root from reading the webserver logs.

Why do I want to put the sitemap files in another directory?

The document root is no good for our deployment method because it is a symlink to the current deployment directory which changes daily. In order for the sitemaps to appear as if they are at the url root (i.e. http://www.example.com/sitemap.xml), we use a alias rule to map XML files to where we actually keep them, e.g. using nginx:

# Alias all XML files (e.g. Rss) to shared directory
location ~* /(.*\.xml)$ {
    alias /var/www/live/shared/xml/$1;    
}

3 Answers 3

5

The official sitemap protocol says it should be located at the root URL that all the files it points to share in common. So if the URLs in your sitemap are like http://www.example.com/site/image1.jpg and http://www.example.com/site/mypage.html, you could put the sitemap.xml file either in http://www.example.com/site/sitemap.xml or http://www.example.com/sitemap.xml.

If you are unable to put a sitemap in that directory for whatever reason, you can put it anywhere on your server as long as your .htaccess or ISAPI Rewrite (or any other URL rewriter) can "pretend" that it's at the root. I've done that successfully using ISAPI Rewrite on an ASP site.

1
  • Thanks, yes we use a Apache alias to make it look like we have our sitemaps in the root URL but they are actually in a shared directory which each deployment will pick up. The problem is getting the sitemap generator to write to the shared directory...
    – Tom
    Jul 27, 2010 at 15:40
2

I have not used that tool so I do not know the direct answer to your question. However, if you can't find a way to put the files elsewhere, you can just copy them to a different folder like this:

cp -t sitemaps/ *.xml

Where sitemaps is the folder name and *.xml selects all the input files, assuming they have a .xml extension. You can create a batch script that runs the sitemap generator and then copies the files, all in one.

Although the official protocol says sitemaps should be in the root, in reality they can go anywhere on the same domain (I have put them in their own sitemaps folder before, with no problems).

You should also create a sitemap index file if you have a lot of sitemaps. This way you only need to submit the index file to each webmaster tools.

4
  • Thanks, yes we are copying them for the moment. But it would be much neater if we could specify a destination folder in the first place.
    – Tom
    Jul 27, 2010 at 15:52
  • This will not work sitemaps.org/protocol.php#location , *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/.*
    – artlung
    Jul 27, 2010 at 16:58
  • @artlung: If I may direct you to the last part of the third paragraph, "I have put them in their own sitemaps folder before, with no problems" ;) I have submitted sitemaps at example.com/sitemaps/sitemap.xml containing URLs like example.com/content/page.html and never got any errors from Google, Yahoo or Bing. Jul 27, 2010 at 23:03
  • okay, if you are comfortable going against the stated syntax, more power to you.
    – artlung
    Jul 27, 2010 at 23:27
1

I've had the same problem and didn't find my answer here or on any google help or config file. So let me share it here !

I read my logs and see :

2012-08-21T17:55:01Z: Writer can't open file: /htdocs/web_sitemap_4149a902_000.xml (2)

You must create a symlink called "htdocs" on your system root directory :

cd /
ln -s /home/www/yoursiterootdir htdocs

Don't ask me if symlinks are working on Windows but I found that command nearly "ln" for cows on Windows (NTFS) !

mklink [[/D] | [/H] | [/J]] linkName target

and then :

2012-08-21T18:05:01Z: Succeeded to generate [Web Sitemap] for site [....]

and where I needed it

enjoy

Your Answer

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

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