Browse files

Parse README as RDoc

  • Loading branch information...
alexrabarts committed Mar 11, 2009
1 parent 97cfd0c commit 708a68d155092939a41b9dc3081a1f3490295a85
Showing with 23 additions and 36 deletions.
  1. +23 −36 README.markdown → README.rdoc
@@ -1,110 +1,97 @@
# BigSitemap
= BigSitemap
BigSitemap is a Sitemap generator specifically designed for large sites (although it works equally well with small sites). It splits large Sitemaps into multiple files, gzips the files to minimize bandwidth usage, batches database queries so it doesn't take your site down, can be set up with just a few lines of code and is compatible with just about any framework.
* Via git: git clone git://
* Via gem: gem install alexrabarts-big_sitemap -s
* Via git:
git clone git://
* Via gem:
gem install alexrabarts-big_sitemap -s
The minimum required to generate a sitemap is:
<pre> => '').add(:model => MyModel, :path => 'my_controller').generate
You can put this in a rake/thor task and create a cron job to run it periodically. It should be enough for most Rails/Merb applications. Note that the methods are chainable, although you can call them on an instance variable if you prefer:
sitemap = => '')
sitemap.add(:model => MyModel, :path => 'my_controller')
### Find Methods
=== Find Methods
Your models must provide either a <code>find_for_sitemap</code> or <code>all</code> class method that returns the instances that are to be included in the sitemap. Additionally, you models must provide a <code>count_for_sitemap</code> or <code>count</code> class method that returns a count of the instances to be included. If you're using ActiveRecord (Rails) or DataMapper then <code>all</code> and <code>count</code> are already provided and you don't need to do anything unless you want to include a subset of records. If you provide your own <code>find_for_sitemap</code> or <code>all</code> method then it should be able to handle the <code>:offset</code> and <code>:limit</code> options, in the same way that ActiveRecord and DataMapper handle them. This is especially important if you have more than 50,000 URLs.
### URL Format
=== URL Format
To generate the URLs, BigSitemap will combine the constructor arguments with the <code>to_param</code> method of each instance returned (provided by ActiveRecord but not DataMapper). If this method is not present, <code>id</code> will be used. The URL is constructed as:
":base_url/:path/:to_param" # (if to_param exists)
":base_url/:path/:id" # (if to_param does not exist)
### Sitemap Location
=== Sitemap Location
BigSitemap knows about the document root of Rails and Merb. If you are using another framework then you can specify the document root with the <code>:document_root</code> option. e.g.:
<pre> => '', :document_root => "#{FOO_ROOT}/httpdocs")
By default, the sitemap files are created under <code>/sitemaps</code>. You can modify this with the <code>:path</code> option:
<pre> => '', :path => 'google-sitemaps') # places Sitemaps under /google-sitemaps
### Cleaning the Sitemaps Directory
=== Cleaning the Sitemaps Directory
Calling the <code>clean</code> method will remove all files from the Sitemaps directory.
### Maximum Number of URLs
=== Maximum Number of URLs
Sitemaps will be split across several files if more than 50,000 records are returned. You can customize this limit with the <code>:max_per_sitemap</code> option:
<pre> => '', :max_per_sitemap => 1000) # Max of 1000 URLs per Sitemap
### Batched Database Queries
=== Batched Database Queries
The database is queried in batches to prevent large SQL select statements from locking the database for too long. By default, the batch size is 1001 (not 1000 due to an obscure bug in DataMapper that appears when an offset of 37000 is used). You can customize the batch size with the <code>:batch_size</code> option:
<pre> => ', :batch_size => 5000) # Database is queried in batches of 5,000
### Search Engine Notification
=== Search Engine Notification
Google, Yahoo!, MSN and Ask are pinged once the Sitemap files are generated. You can turn one or more of these off:
:base_url => '',
:ping_google => false,
:ping_yahoo => false,
:ping_msn => false,
:ping_ask => false
You must provide an App ID in order to ping Yahoo! (more info at
<pre> => '', :yahoo_app_id => 'myYahooAppId') # Yahoo! will now be pinged
If your database is likely to shrink during the time it takes to create the sitemap then you might run into problems (the final, batched SQL select will overrun by setting a limit that is too large since it is calculated from the count, which is queried at the very beginning). Patches welcome!
* Support for priority and changefreq (currently hard-coded to 'weekly')
Thanks to Alastair Brunton and Harry Love, who's work provided a starting point for this library.
Copyright (c) 2009 Stateless Systems ( See LICENSE for details.
Copyright (c) 2009 Stateless Systems ( See LICENSE for details.

0 comments on commit 708a68d

Please sign in to comment.