TODO: <Insert clever marketing phrase here>
DuckMap supports the following HTML Meta Tags.
To include the meta tags in your app, simply add the view helper method: sitemapmetatag.
<head> <%= sitemap_meta_tag %> </head>
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 end
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 end end
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.
<url> <loc>http://www.jeffduckett.com/blog/15/route-filters.html</loc> <lastmod>2013-02-26T20:40:41+00:00</lastmod> <changefreq>monthly</changefreq> <priority>0.5</priority> </url> <head> <link href="https://www.jeffduckett.com/blog/15/route-filters.html" rel="canonical" /> <meta content="02/26/2013 08:40:41 PM" name="Last-Modified" /> </head>
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.