Crawlable

Super DRY Sitemaps for Rails and Sinatra Apps (works on Heroku!)

Usage

Install

sudo gem install crawlable

Sitemap (config/sitemap.rb)

Sitemap "http://www.example.com" do
  link articles_path, :priority => 0.7, :changes => 'daily'

  Post.all.each do |a|
    link articles_path(a), :updated_at => a.updated_at do
      image images_path(a.featured_image)
    end
  end
end

Result

<?xml version="1.0"?>
<urlset>
  <url>
    <loc>/articles</loc>
    <lastmod>2010-06-20T09:38:26+00:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.7</priority>
  </url>
  <url>
    <loc>/articles/title-0</loc>
    <lastmod>2010-06-20T09:38:26+00:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>/articles/title-1</loc>
    <lastmod>2010-06-20T09:38:26+00:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.5</priority>
  </url>
  ...
</urlset>

Feed

Feed do
  title "My RSS Feed"
  author "Lance Pollard"
  description "Something nice and tidy"

  Post.all.each do |a|
    entry "/posts/#{a.to_param}", :updated_at => a.updated_at, :title => a.title
  end
end

Features

  • Works on Heroku
  • Pings Google, Bing, Yahoo!, and Ask whenever anything changes

Alternatives

Resources