Down And Dirty Google Sitemap Generation For Wordpress

December 21, 2006 – 6:43 am

by Darren

Everyone needs to get their blog into Google Sitemaps. There are a few plugins out there that will do the job, but I’ve come up with my own down and dirty method which is working quite well. I recently wrote up the how Google Sitemaps has helped me and Hart had some further questions, so hopefully they can be answered in this post.

Steps to adding a Google Sitemap with this simple system

1) Copy and Paste this script into a file in the root of your document structure. Name the file anything you want, but use a .php extension.

2) Change the settings in the PHP script to reflect you username, password, and database

3) Access the PHP page in your browser, and you should now see the properly rendered XML in your browser.

4) Login to your Google Sitemaps account and click “Add A Sitemap”. Paste the URL of your PHP script into the box and submit. If all is well, the Sitemap will be downloaded and show details of how many URLs it grabbed.

This system has worked very well for me for the last month or so, and it’s really easy to implement. I haven’t tested it on any other platforms, but it works with current versions of PHP and MySQL.

I’ve also went one step further and added an actual sitemap to my Wordpress blogs, because I think it improves spiderability over the default category system. I can cover how to do that in a seperate post, if there’s enough interest.

Let me know if you have any questions.

  1. 5 Responses to “Down And Dirty Google Sitemap Generation For Wordpress”

  2. Thanks Darren, I will try it out!

    Previously, I just published my feeds to be 99 post long, and then I used that as a sitemap!

    By Kian Ann on Dec 21, 2006

  3. Hopefully it will work for you.

    By Darren on Dec 21, 2006

  4. Very timely Darren! I’ve been adding the Google Sitemap Plugin and setting up all of my sites at http://Google.com/webmasters/sitemaps/ .. except the plugin was majorly conflicting with about 6 sites that was using the DD Sitemap plugin for my archives.

    So far I have added your text to two sites just now and, successfully set that as the sitemap URL.

    This is new to me .. almost 80% of my sites were generating a “Paths Don’t Match” error (re: with www and without www) .. and I have been going around to all my .htaccess files and adding this at the bottom

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

    Already I see the errors disappearing on MySites on the google site.

    By HART (1-800-HART) on Dec 21, 2006

  5. Darren,

    I would absolutely like to know how you put together your sitemap. I am going to try your google sitemap as well. Great idea, thanks!

    Dr. Dan from SI

    By Dan on Dec 21, 2006

  6. Dan, I’ll make a seperate post for the onsite Sitemap, because that’s a pretty slick feature I haven’t seen around. It helps 1) spread PR and 2) make sure ALL pages are spidered

    Hart,

    I’m glad to hear this worked out. Your rewrite should probably be set like:

    RewriteCond %{HTTP_HOST} ^blog-republic\.com
    RewriteRule (.*) http://www.blog-republic.com/$1 [R=301,L]

    Don’t forget just set the Preferred domain in Sitemaps! That will “fix it” in Google. But then set the .htaccess rules in order to “fix it” in MSN and Yahoo.

    BTW, MSN and Yahoo now use the Google Sitemaps protocol, so there’s probably somewhere to upload the Sitemap XML file, but I haven’t seen it yet.

    By Darren on Dec 22, 2006

Sorry, comments for this entry are closed at this time.