Plugins - Generate Sitemap Task
Add to favoritesGenerate Sitemap Rake Task
This is a Rails plugin that consists of a rake task generate a sitemap.xml The task crawls a domain (default is localhost:3000) for all it’s url’s, then builds the sitemap.xml file in public.
Since this simply crawls a domain for url’s, this could be used to generate sitemaps for any site, not just a Rails application
Requirements
Both of these are available via RubyGems Hpricot - http://code.whytheluckystiff.net/hpricot/ Builder - http://rubyforge.org/projects/builder/
Installation
Any of the typical plugin installation methods will work.
script/plugin install svn://chriscodes.homelinux.org/rails_plugins/generate_sitemap
or add a svn:externals entry to vendor/plugins
script/plugin install -x svn://chriscodes.homelinux.org/rails_plugins/generate_sitemap
or from inside your vendor/plugins directory
svn co svn://chriscodes.homelinux.org/rails_plugins/generate_sitemap generate_sitemap
Configuration/Usage
Open tasks/generate_sitemap.rake and set the DOMAIN constant to your domain (DOMAIN is set to localhost:3000 by default, and will use that in the sitemap urls)
You can optionally set the changefreq element, or add the other available elements in the building of the xml. (http://www.sitemaps.org/protocol.php) I haven’t devised a way to set this dynamically, as most pages will vary.
Run the task with the command
rake plugin:generate_sitemap
Go to http://localhost:3000/sitemap.xml (or open public/sitemap.xml)
TODO
- set changefreq, lastmod, priority dynamically during generation - allow generation of sitemap index files - write tests - allow for exclusions to be specified in an array
More Info
http://www.sitemaps.org/protocol.php
Questions, comments, patches, etc. can be sent to
chris AT chriscodes DOT com
http://chriscodes.com/articles/view/54
svn://chriscodes.homelinux.org/rails_plugins/generate_sitemap
Rails' (MIT)
Assets

The plugin repository is temporarily unavailable. You can get the latest tarball here: http://chriscodes.com/generate_sitemap.tar.gz