views:

419

answers:

3

Hi,

I did a quick Google search and didn't see anything super-great to automate creation and updating of my google sitemap for the ruby on rails app. Any suggestions?

+3  A: 

Hello,

I really wouldn't recommend using controller and simply routing to it like '/sitemap.xml', because if your sitemaps will grow it will waste resourses. It would be best to make a rake task and regenerate sitemaps every night or so, depending on how frequently the content changes.

If your site does not have anywhere near 50000 pages and you're not planing to have more then you can fit in one sitemap file then I suggest you use "Google Sitemaps with Ruby on Rails, Capistrano, and Cron" I know it works decently because I'm using it sucessfully atm.

Note: I would not suggest using authors way of copying sitemaps every time when deployment task is run, in my opinion it's not clean. It's better to use shared directory and symlink to it on deployment, then you'll be sure to have only one version of files and now wasting space if extra copies get left behind. I have this in my deploy.rb:

desc "Symlink the upload directories"
task :before_symlink do
  run "rm -drf #{release_path}/public/sitemaps"
  run "ln -s #{shared_path}/sitemaps #{release_path}/public/sitemaps"
end

Also you can use "Big sitemap" gem, but I have found it just now and can't tell you how good it is. It looks like it's really easy to setup this gem and it also uses your rails routes for link generation, so you'll have one problem less to solve than with the first solution.

Rytis Lukoševičius
I looked for big sitemap gem....doesn't look like it's there anymore...have you changed the wy you do it or still create it?
Angela
Maybe there was a glitch on github, because the link opens ok and the gem is still there.
Rytis Lukoševičius
+2  A: 
John Topley
ah yes I've seen people post for how they do their blog....I'd have to do this for pretty much every model then, no? Is there a way to have it just spider?
Angela
We display Reviews, Vendors and so would that mean under index above I would duplicate code for both Reviews and Vendors model?
Angela
You should have a <url> element for each publically accessible entity that you want in the sitemap. So perhaps you'd iterate over all Vendors and for each Vendor iterate over all Reviews. It depends how your model associations are set up.
John Topley
A: 

The Google Sitemap Generator is Google's official release. It's easy to set up and configure.

http://code.google.com/p/googlesitemapgenerator/

MikeH
I don't think that works within rails....seems like a separate application
Angela
It is a separate application, but it works with any website, including Rails apps. You install it on your server and it takes care of generating the sitemap for you. It has a decent admin panel GUI where you can customize what urls are included in the sitemap, how often the sitemap gets created, etc. It also auto-submits to all the search engines for you. I don't see any reason why it's better to roll your own from within the application. I think this google solution probably gives you more functionality and it's easy to set up.
MikeH