Support

Files

Links

Requirements

Videos

Series: Duck Map

Duck Map Quick Start

Previous Article


Created: 02/19/2013 10:39:35 AM  Last Updated: 02/25/2014 04:25:44 PM

Tags:Duck Map, Sitemap, Ruby On Rails, Rails 3.x

Duck Map Quick Start

Including a sitemap into your Rails app is very easy with Duck Map. The following steps are taken directly from the README.md included in the duck_map.gem

# open a shell and navigate to a work directory.
# create a Rails app
rails new test.com --skip-bundle

# add the following to your Rails app test.com/Gemfile
gem 'duck_map'

# depending on your Rails version, you may have to add the following lines as well.
gem 'execjs'
gem 'therubyracer'

# make sure you have all the gems, etc.
bundle install

# create a controller
rails g controller home

# create a route in config/routes.rb
root :to => 'home#index'

# start the server
rails s

# view the sitemap
http://localhost:3000/sitemap.xml

# if you view the HTML source of: http://localhost:3000/sitemap.xml
# you should see something similar to the following:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>http://localhost:3000/</loc>
    <lastmod>2011-10-27T13:02:15+00:00</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
</urlset>

You can download the support file and run the actual app used in the video. Be sure to run: bundle install !!