Setting up a google sitemap is an easy way to force google to notice your site. A sitemap is just a simple xml file that lists every url you want google to know about. They are especially useful if...
You also get the added benefit of seeing where the googlebot looked last, where it encountered errors, and your sites top search keywords.
So it's helpful, but is it easy to setup? If you're using Ruby on Rails (or any other ruby based framework) it's cake!
This script will collect all relevant urls and create a file at RAILS_ROOT/public/sitemap.xml that contains info about each url. For example, let's pretend we have a site devoted to hippo pictures, our script would look like this...
#!/usr/bin/env ruby ENV['RAILS_ENV'] ||= "production" Dir.chdir(File.expand_path(File.dirname(__FILE__) + "/..")) # Change current directory to RAILS_ROOT require "config/environment" # Start up rails # These two lines make life super easy... It allows you to call url_for/link_to outside of a controller or view include ActionController::UrlWriter default_url_options[:host] = 'www.hippos-are-awesome.com' filename = "#{RAILS_ROOT}/public/sitemap.xml" hippo_pics = HippoPic.find(:all) # Such a wonderful collection File.open(filename, "w") do |file| xml = Builder::XmlMarkup.new(:target => file, :indent => 2) # This xml.instruct! xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do for hippo_pic in hippo_pics xml.url do xml.loc url_for(:controller => "hippos", :id => hippo_pic.id) xml.lastmod hippo_pic.updated_at.xmlschema xml.changefreq "weekly" xml.priority 0.5 end end end end
For more info about what the lastmod, changefreq and priority mean in the sitemap, google explains it all here. Basically they tell google which urls are more important.
Just switch to the user that runs your ruby apps and add this to its crontab.
20 2 * * * PATH_TO_RAILS_APP/script/sitemap # Runs the sitemap script every morning
Head over to google's webmaster tools and follow the instructions on how to point google to your sitemap
That's it. Some other additional things to consider are
Recent Posts