Sitemaps Plugin

  • Tags: /
  • Latest: 0.2.0
  • Last Updated: 18 February 2014
  • Grails version: 2.0 > *
0 vote
Dependency:
compile ":sitemaps:0.2.0"

 Documentation  Source  Issues

Summary

Creates a standard interface for building sitemaps via a common Sitemap Artefact.

Installation

plugins {
  compile ':sitemaps:0.1.0'
}

Description

The grails sitemaps plugin provides a common interface for building out sitemaps. This supports generating sitemaps both in a single application environment as well as a plugin heavy environment. You can simply create Sitemap classes in the grails-app/sitemaps folder and your good to go.

To get started simply create a sitemap class in the grails-app/sitemaps folder with the following implementation:

This can be done using the grails create-sitemap generator.

class CmsSitemap {
  static sitemap = "cms"

List getSitemapUrls() { return [ [url: 'http://mysite.com/page', lastmod: new Date()], [url: 'http://mysite.com/page2', lastmod: new Date(), priority: 0.1] [url: 'http://mysite.com/page3', lastmod: new Date(), changefreq: 'weekly'] ] }

String getDefaultChangeFrequency() { return "monthly" }

Double getDefaultPriority() { return 1.0 } }

As long as the 3 methods above are defined, you are good to go. The sitemap static variable defines the url name to represent this particular sitemap. In the case of the example above, the sitemap would be viewable with the url: http://mysite.com/sitemap/cms.xml .

All sitemaps are combined into a single sitemap set via the /sitemap.xml url mapping.

This plugin also takes advantage of the grails cache plugin to cache your sitemaps. These sitemap caches can be evicted by using the sitemapService.evictCache() method.