Rake task to ping Google

Written on 10 jun 2009 and tagged ruby, rake, google, ping, automation, blog, blogging, script

Creating and publishing a sitemap XML file helps search engines find and index all of your content. Most CMS alert Google to come check out your sitemap file, but here’s a Rake task to do it yourself.

This site is generated using Jekyll, a static website generator. I’ve got a sitemap file set up to include links to all my pages and posts. All I need now is to tell Google the file has changed – and do that every time I push changes to my server.

Rake to the rescue

I’ve set up the following Rake task to handle pinging Google for me:

desc 'Notify Google of the new sitemap'
task :sitemap do
    require 'net/http'
    require 'uri'
        '/webmasters/tools/ping?sitemap=' +

Running rake sitemap is now enough to let Google know that my sitemap has changed. I have chained this task in my publication process, so that every time I run rake publish my site will be re-generated and published, and Google will be notified.

I’ve also set up a task to ping ping-o-matic. You see my entire Rakefile at Github.

You cannot leave comments on my site, but you can always tweet questions or comments at me: @avdgaag.