Scribble Designs: Web Design in Northern Ireland.

Installing Drupal’s Google Sitemaps Module

By Gerard McGarry on 17th July 2007, filed in Drupal, Search Engine Optimisation. You can leave a response below. Tags: , ,

I’ve been working a lot with Drupal recently as a content management system for a variety of websites. I must admit, I love the flexibility of the system. However, one thing the default install is missing is the ability to automatically generate sitemaps for search engines to crawl.

Providing a sitemap to the search engines basically gives them an inventory of the pages in your site. It’s useful in helping them to find and index older and possibly orphaned content in your website that they wouldn’t otherwise be able to find.

Basic XML Sitemap Setup

  • First, download the Google Sitemap module for Drupal. Upload the gsitemap folder to your Drupal installation into sites/all/modules. If the modules folder doesn’t exist, you may need to create it.
  • Once you’ve uploaded the module, go to Administer | Site Building | Modules, and activate the module labelled XML Sitemap.
  • Now, you’ll need to configure the module. Got to Administer | Site Configuration | XML Sitemap and set the options accordingly. By default, the “Submit To Google” option is selected, but you might also want to automatically submit to Yahoo! and Ask. In fact, I recommend it. You should also select to submit sitemap when the site is updated and when cron is run. Cron tasks in Drupal automatically perform regular maintenance on your Drupal installation. It’s recommended to set this up. (I may cover this in a later article)

Problems I Encountered During Sitemap Configuration

After following those ‘default’ steps to setup, I attempted to access my sitemap. No luck, it gave a parse error in FireFox. Upon further investigation, the file was empty. So the sitemap hadn’t been generated. If you encounter this problem, try these steps:

  • Browse to Administer | Site Configuration | File System.
  • In the Temporary Directory box, remove the forward-slash character from the start of /tmp. Save the new settings. You should see a notice that “The directory tmp has been created”
  • Try to access your sitemap file again (should be at http://yoursite.com/sitemap.xml). This time you should see the sitemap that has been generated.
  • Now that the sitemap has been created, you can force a cron run to ping Google, Yahoo! and Ask. Simply visit Administer | Logs | Status Reports and click the link that says “run cron manually”. Follow this up by viewing the Recent Log Entries Report where you should see a number of entries confirming submission to the various search engines.

For bonus points, you could (and should) configure your robots.txt file for sitemap autodiscovery.

If you enjoyed this post, please vote for it at:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Ma.gnolia
  • NewsVine
  • Slashdot
  • Propeller

7 Responses to “Installing Drupal’s Google Sitemaps Module”

  1. Free as in Time » Blog Archive » Drupal Thursday 19/07/2007 said on July 19th, 2007 at 7:23 pm :

    [...] Installing Drupal’s Google Sitemaps Module – Google is my dear and glorious leader. Providing a sitemap to the search engines basically gives them an inventory of the pages in your site. It’s useful in helping them to find and index older and possibly orphaned content in your website that they wouldn’t otherwise be able to find. [...]

  2. Del.icio.us bookmarks: Juli 18th - Juli 20th | Bloganbieter.de Blog said on July 21st, 2007 at 4:26 pm :

    [...] Installing Drupals Google Sitemaps Module – [...]

  3. Justin said on August 13th, 2007 at 5:33 pm :

    Great post, Gerard.

    Your advice about the /tmp directory is especially useful. I learned the hard way that permissions issues on that directory can cause the installation to fail miserably.

    For instance, if you happen to have your Drupal site hosted elsewhere and another of your hosting company’s customers also uses Drupal and the Sitemaps module, the other customer might have already created the directory this module wants to use by default. In that situation, the directory will probably only be writable by the first user’s account, meaning the second user is SOL…

    Unless, of course, they follow your advice and change the temporary directory path to one relative to their own Drupal installation.

    Again, great post.

    Justin

  4. finley said on August 29th, 2007 at 7:58 am :

    Hi Gerard,
    I have the same problem, with many drupal 5 installation that can produce just empy sitemaps.
    Changing tmp dir doesn’t help me much.
    Any other idea?

  5. Gerard McGarry said on September 1st, 2007 at 2:08 pm :

    Finley – I emailed this answer to you, but am posting it here for completeness (and so that people don’t think I ignore the comments!):

    If the sitemap.xml file exists and is blank, perhaps the system doesn’t have write access to it? Maybe try giving it CHMOD 777 to open up the permissions and try to generate the sitemap again.

    Also, make sure that sitemap happens as part of your Cron run and that cron runs regularly for your site – it’ll keep the sitemap up to date as well as perform other optimisations that keep your Drupal installation happy.

  6. Puraz said on October 31st, 2007 at 2:37 pm :

    Hey Gerard

    Thanks for this write up. Insightful and informative. I didn’t run into any problems, my sitemap worked without a problem, but it was good to know that this module works.

    Thanks again.
    Cheers.

  7. S said on November 8th, 2007 at 9:38 am :

    Hi,

    I also faced this problem. The sitemap.xml file is empty(even after cron jobs) and parse error is generated in firefox.

    I tried to change the file permissions to 777. But no use.

    The solution is removing / slash !

    Thanks for your help.

Leave a Reply