Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

DuckMap Meta Tags

DuckMap supports the following HTML Meta Tags.

  • Canonical URL
  • Description
  • Keywords
  • Last Modified Date
  • Title

To include the meta tags in your app, simply add the view helper method: sitemapmetatag.

  <%= sitemap_meta_tag %>

The default behavior is to acquire values from the first model found on a controller. The model is interrogated for the following attributes: :canonical, :description, :keywords, :lastmod, and :title. If the attribute exists on the model, then, the value is used. You have the option of mapping attributes to your model.

For example, here we are mapping the description attribute to content and keywords to tags.

class Book < ActiveRecord::Base

  attr_accessible :author, :content, :tags, :title

  acts_as_sitemap description: :content, keywords: :tags


NOTE: You can use actsassitemap on the controller or model. The result will be the same.

Mapping attributes can be very useful when handling special cases. For instance, let's say you have some very unusual requirement for a canonical url. You could handle it in a method on your model and map to it.

class Book < ActiveRecord::Base

  attr_accessible :author, :content, :tags, :title

  acts_as_sitemap canonical: :my_canonical

  def my_canonical
    value = ""

    # perform special handling here...

    return value


Synchronizing HTML Meta Tags And Sitemap Values

One of the challenges DuckMap attempts to meet is keeping common attributes between HTML Meta Tags and sitemaps synchronized.

The two common attributes are Last Modified Date and Url. Below is an example of both meta tag and sitemap.


  <link href="" rel="canonical" />
  <meta content="02/26/2013 08:40:41 PM" name="Last-Modified" />

You can see that both values match. The actual source of the values will differ depending on your configuration, however, both url and last modified date should always match within the sitemap and meta tags.