Update August 13th, 2011: I’ve switched over and am giving a new plugin a try. It’s called Better WordPress Google XML Sitemaps (with sitemapindex and Multi-site support) and so far so good.
What really convinced me to look at this one is that the guys at WP Engine added it to their Curated Plugins list. If they are giving this a try then that’s really all justification I need.
Update July 23rd, 2011: These instructions still work for the newer 3.2.5 version as well. While this simple modification is useful, I plan to switch the to the 4.0 beta.
Update: Arne has posted an early test version on the WordPress support forums here. At this stage it’s not yet ready for release. If you would like to test that version, you can support Arne’s effort by downloading and reporting any issues to him on that thread.
I’m lazy and have not yet tried the early release version.
——————————————————–
WordPress 3.0′s Multisite feature is cool and useful. The Google (XML) Sitemaps Generator plugin is also cool and useful. Unfortunately Arne Brachhold’s excellent plugin does not work with multisite blogs.
If you activate the plugin on a multisite enabled WordPress install, you get this error message.

Which is a shame, but it did not take me a long time to find a work around. My setup is using multisite with sub-domains and with the Domain Mapping plugin. These instructions are for the 3.2.4 version of the plugin.
1. Modify the plugin
Edit the file wp-content/plugins/google-sitemap-generator/sitemap.php and comment out lines 53 to 58 to look like this
//Check for 3.0 multisite, NOT supported yet!
// if((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) || (function_exists('is_multisite') && is_multisite())) {
// if(function_exists('is_super_admin') && is_super_admin()) {
// add_action('admin_notices', array('GoogleSitemapGeneratorLoader', 'AddMultisiteWarning'));
// }
//
// return;
// }
You can delete these lines, but I prefer to comment them out. All this does is prevent the plugin from detecting the multisite setup and not becoming active.
2. Get your rewrite rules ready
In your blog’s .htaccess file add these lines above your WordPress rules
RewriteRule ^sitemap.xml sitemap-%{SERVER_NAME}.xml [L]
RewriteRule ^sitemap.xml.gz sitemap-%{SERVER_NAME}.xml.gz [L]
This will come in handy later.
3. Activate the plugin and set these options
Now on each of your sites in your WordPress network, activate the Google (XML) Sitemap plugin. Do not Network Activate it.
Now got to your XML-Sitemap options page and for “Location of your sitemap file” select Custom location.

In the custom location change your change the file name sitemap.xml to sitemap-yourblogservername.xml. My server name is blog.dembowski.net so I’m using sitemap-blog.dembowski.net.xml. Save the options.
Look in your WordPress installation’s root and check if you have sitemap.xml or sitemap.xml.gz. If you do then delete them both.
Now at the top of that options page, click on “rebuild the sitemap manually” and confirm that your new sitemap-yourblogservername.xml has been created.
4. Test and confirm that this worked
Now test two things. Start by pointing your browser to http://yourblogservername/sitemap.xml and then http://yourblogservername/sitemap-yourblogservername.xml. If you setup your .htaccess rewrite rules correctly, then both URLs should work.
Load up your WordPress generated robots.txt file via http://yourblogservername/robots.txt and look at the Sitemap line. Mine reads like this
User-agent: * Disallow: Sitemap: http://blog.dembowski.net/sitemap-blog.dembowski.net.xml.gz
I have that rewrite rule in case the default location for the sitemap is used. When you load the sitemap via the normal location, the rewite rule sends it to the correct location. The second gziped sitemap URL is fine.
There should be no real sitemap.xml or sitemap.xml.gz files in your blog’s root directory. Instead, each sitemap file should have your virtual WordPress network names instead.
5. Rinse and repeat
Repeat this process for each site in your WordPress Network and you can continue to use this sitemap plugin. You will need to activate the plugin in each of your sites and change sitemap.xml to include the site name just as I outline in step 3.
6. The caveat
If this works for you, great! But if it doesn’t, please don’t bug Arne. If and when he makes his plugin multisite compatible, then it will be probably a better solution than this one. I’m not seeing any PHP errors or warning in my log files, but there may be reasons why this is not a good idea.
Also, when you modify your copy of a plugin in the WordPress plugin repository and that plugin is updated you will lose your edits from step 1 when you update the plugin.
In the meanwhile, I can continue to use this excellent plugin.
Thanks for this great tutorial.
It’s even more elegant, to create a subdirectory for each set of sitemaps.
So the RewriteRules would look like:
RewriteRule ^sitemap.xml.gz sitemaps/%{SERVER_NAME}/sitemap.xml.gz [L] RewriteRule ^sitemap.xml sitemaps/%{SERVER_NAME}/sitemap.xml [L]As mentioned before in exact this order, gz first, then the one without. Otherwise the first rule catches them all.
The third step is spare to edit for each blog, if you replace the following into sitemap-core.php in function GetXmlPath, line 1386:
return $this->GetHomePath() . $this->GetOption("b_filename");with this:
$dir = $this->GetHomePath() . 'sitemaps/'.trailingslashit($_SERVER['HTTP_HOST']); if(!file_exists($dir)) { mkdir($dir); clearstatcache(); sleep(1); } return $dir . $this->GetOption("b_filename");This will automatically create a subdir for each blog containing the sitemaps therefor.
Step 4 is also spare, if you don’t use a physical robots.txt, but the WordPress virtual one instead. You only need to check “Add the sitemap to the virtual robots.txt” in the XML Sitemap options and are done with your hand work.
Markus,
I’m glad you liked the post. I’ve added some formatting to your comment so that readers can see more clearly what you are refering to.
Your edits would have been a more elegant solution: fortunately Arne is working on a version of his plugin that visualizes the sitemap.xml files.
No more real files, it’s a more dynamic solution. Of course, this may mean more CPU time but I’m confident that the next release will be worth the wait.
Delicious Bookmarks for September 3rd through September 4th « Lâmôlabs
[...] Google XML Sitemaps and WordPress Multisite – September 4th %(postalicious-tags)( tags: wordpress google sitemap xml plugins multisite wp development tip trick workaround )% [...]
Google XML Sitemap plugin on multi-blog by wordpress 3.0 » daruyanagi.net
[...] Google XML Sitemaps and WordPress Multisite wp-content/plugins へ解凍フォルダをコピー [↩]以下に述べる .htaccess [...]
Thanks for the tutorial. I also use a subdomain network with domain mapping, but the generated xml file has the original domain in the tags instead of the mapped domain. For example:
Network: network.com
Site: site.network.com
http://www.betterdomain.com is mapped to site.network.com
In the generated sitemap I’m getting this:
I need it to be this instead:
Any ideas? Thanks.
On the last comment… it’s missing all the tags, but hopefully you get the idea.
I think either the .htaccess rules are not working (and you are getting a different file than you intended) or the domain mapping is not setup correctly.
When the sitemap.xml is generated, does it actually create a file called sitemap-www.betterdomain.com.xml?
Thanks for the response. Yes, when the files are generated they use the correct names I assigned in the respective “Custom location” sections, and they are including all the correct url entries. The only problem is the loc tags in each url entry include the original domain instead of the mapped primary domain. (I didn’t specify earlier, but in my example the “www.betterdomain.com” is set to be the Primary domain.)
As for domain mapping, the site is working correctly. i.e., I am able to access my site from either domain with it redirecting to the primary domain.
What should I do so that the Primary domain is used in the url entries of the xml file?
That’s a tough one. It looks like the only thing that is different is that I don’t use the domain mapping plugin to mask my primary site.
The only thing I can think of is to re-confirm your settings or try out the development version at this location:
http://wordpress.org/extend/plugins/google-sitemap-generator/download/
Thanks, Jan. I’ll see what I can do.
Thanks for the info. FYI, one guy reposted your article without mentioning you at [splog URL removed]
Yep, thanks I saw that too.
What can you do, they’re spammers. They run afoul of my hotlink image protection and are showing people an image of Hello Kitty Superman.
Since I’m lazy to make all the changes, I finally decided to try out the beta version from Arne at the post you mentioned. Lastest version was 4.0b2 released two days ago. Unfortunately it doesn’t seem to work with subdomains. I’m waiting for Arne’s reponse now. If it turns out to be true, I’ll have to go for the difficult way in your post, it isn’t too hard to follow though, since you explained everything clearly enough.
サブドメイン運用のGoogle XML Sitemapsプラグインのマルチサイト対応方法 - web.londoner25.net
[...] http://blog.dembowski.net/2010/06/09/google-xml-sitemaps-and-wordpress-multisite/ [...]
hello, i followed the steps, but i found that all sub-directory blog share the same site.
Am i doing something wrong?
Anyone can help?
Thanks,
Felix
10x a lot, seems to work great. It also works with the WordPress MU Sitewide Tags Pages plugin, so everything is great.
Looks like Arne still hasn’t made the multisite version public. Fortunately the beta version works fine.
Looking at the problem, it’s not really a trivial update.
With 3.1 just around the corner maybe Arne will polish off that version.
I went through all the steps, got the same robot.txt file that you got with the gz on the end, but my links to test it still don’t work with or without the gz on the end.
Any idea what I could have done wrong?
I’m not getting the incompatibility error message anymore on my dashboard for the plugin. It appears that my sitemap was manually rebuilt successfully.
I have my custom locations set as follows:
/home/digang/public_html/angeladigiovanni.com/sitemap.xml
http://angeladigiovanni.com/sitemap-angeladigiovanni.com.xml
I commented out the lines in the plugin file with /* */.
I put my rewrite rules in the .htaccess file at the top, looking like this:
RewriteRule ^sitemap.xml sitemap-%{SERVER_NAME}.xml [L] RewriteRule ^sitemap.xml.gz sitemap-%{SERVER_NAME}.xml.gz [L] RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L]Yet I can’t get those test links to work.
Any thoughts?
Thanks in advance!
Angela
Angela,
That looks like that should work, but when I visit your web site I also get a ’404 Page not found’ error.
Try something: copy the sitemap-angeladigiovanni.com.xml to test.xml and see if you can load that in your web browser.
The Great WordPress Multisite Experiment of 2011 | Oikos
[...] yet work with the Multisite setup. There is a new version in beta that addresses this and a workaround that can be used in the [...]
where is the real sitemap-yourblogservername.xml and/or sitemap-yourblogservername.xml.gz files?
Daplun,
See step #3. They are stored in my blog’s root directory.
The Great WordPress Multisite Experiment of 2011 | Oikos
[...] yet work with the Multisite setup. There is a new version in beta that addresses this and a workaround that can be used in the meantime, but Plugin compatibility will, I suspect, continue to be an [...]
» WP3.0のマルチサイトでGoogleXMLSitemapプラグインを使う
[...] 前に「WordPress 3.0のインストール」で書いたのたけど、WordPress3.0のマルチサイト環境において、現時点では「GoogleXMLSitemapプラグイン」を使用することができない。マルチサイトでの 子サイトはそれぞれ独立したサイトでありながら独自のXML Sitemapを生成しないため、ウェブマスターツールも上手く読み込んでくれないのだ。それぞれのサイトの「sitemap.xml」が同名で同じ場所に書き出されてしまうことが原因だ。対応版がリリースされるまではそんなに時間はかからないだろうけれど、それでもSitemapの自動作成ができないのは不便。なにか方法はないものかと探してみたら、「Google XML Sitemaps and WordPress Multisite」をみつけることができた。 [...]
This works like a breeze !
Thanks for sharing.
We were not able to find a plugin for XMS sitemap after we upgraded to the WP Multisite functionality.
We patiently followed all the steps mentioned here and this tutorial finally did the trick for us.
It was very helpful.
Hi,
thanks for the various comments and the detailed tutorial. Save me a lot of grey hairs.
Thanks
Tim
I followed all the step but still can’t get it to work. I am sure it is me. Are there any other oprion or other plugins for multi site WP sitemaps?
Thanks in advance – John
The easiest thing to do is search though http://wordpress.org/extend/plugins/ and look for “XML sitemaps”.
I am sure that there is at least one available that can handle mutlisite installations of WordPress.
every thing is working fine but look the sitemap is not working without full domain name (www) fun portal
and working fine with fun portal
now plz tell me that how can i view my sitemap with both urls with (www) and without (www)
my google webmaster tool is not accepting my sitemap becoz i add my domian there without (www)
That’s a tough one. This trick depends on you modifying your .htaccess file as well as having your Apache virtual servers setup correctly. It sounds as if that second part is not correct.
The only advice I can offer is to consider switching to another Sitemap plugin. The one I’ve put into the update on top just works without any changes or .htaccess updates.
在wordpress mu中使用Google XML Sitemaps - ORZ部落閣
[...] 我就碰到了这样的事情,好在从国外某个网站上看到了临时的解决办法,经过测试,该方法也适用于以子目录(Sub-Directory)形式安装的多站点,当然,根据原文作者的叙述我们知道,它是适用于以子域名(Sub-Domain)方式启用的多站点的。 [...]