On the fly sitemap generation for Grails applications, see sitemaps.org for more information about sitemaps.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 103 commits ahead of kimble:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Grails Sitemapper Plugin

Build Status Analytics


Create sitemaps on the fly. Easily adds support for dynamic or static sitemaps for your site.

About sitemaps

Sitemaps allows search engines to quickly spot changes on your site without crawling the whole page. Note that search engines are obviously not compelled to index your sites faster if you add a sitemap, but chances are that a lot of them will. Have a look at sitemaps.org for more information about sitemaps.


In BuildConfig.groovy, add the dependency to "plugins" section:

plugins {
    compile ':sitemapper:0.9'

Change the version to reflect the actual version you would like to use.

Quick Start

Create sitemap generator class by

grails create-sitemap
> Add pagination support? [y,n] 

Select "y" if you exceed established limits (like 50 000 URLS per file) in one sitemap group.

Then script create sample artefact in grails-app/sitemaps folder,

Standard sitemap (single file):

import grails.plugin.sitemapper.Sitemapper
import static grails.plugin.sitemapper.ContentChangeFrequency.MONTHLY

class ForumSitemapper implements Sitemapper {
    Date previousUpdate = new Date()
    // The `withEntryWriter` method will be invoked each time the sitemap is requested.
    void withEntryWriter(EntryWriter entryWriter) {
        entryWriter.addEntry '/forum/topic1', new Date() - 1
        entryWriter.addEntry '/forum/topic2', new Date(), MONTHLY, 0.5
        // ...

Sitemaps group (multiple files):

import grails.plugin.sitemapper.EntryWriter
import grails.plugin.sitemapper.impl.PaginationSitemapper

class MessagesSitemapper extends PaginationSitemapper {
    Date previousUpdate = new Date()

    final int perPageCount = 50000

    long getTotalCount() {
    void withEntryWriter(EntryWriter entryWriter) {
        def items = Message.list([
                max: perPageCount, 
                offset: pageIndex * perPageCount, 
                sort: 'createdDate', 
                order: 'asc'
        items.each {
            entryWriter.addEntry("/messages/${it.id}", it.createdDate)


On production mode plugin use gzip compression, so you can check sitemap index file by:


On the development mode directly:



To change sitemap filename (only filename, exclude extension), you can set the following in Config.groovy:

sitemap.prefix = 'mysitemap'

To disable gzip on production mode:

environments {
    production {
        sitemap.gzip = false

Static files generation

Suggest use this plugin under proxy servers like nginx or Apache HTTP Server with enabled caching.

Anyway, plugin also support to generate static files by script:

grails generate-static-sitemaps

After running this script you can see result in target/sitemaps folder.

Search engine ping (EXPERIMENTAL)

Add something like this to your Config.groovy file. The %s will be substituted with sitemap uri.

sitemapConsumers {
    bing 'http://www.bing.com/webmaster/ping.aspx?siteMap=%s'
    google 'http://www.google.com/webmasters/sitemaps/ping?sitemap=%s'

Important! This has not yet been fully implemented.


  1. Implement support for search engine ping - in (slow) progress.
  2. Support for Grails Cache plugin.

Copyright and license

Copyright 2010-2015 Kim A. Betti, Alexey Zhokhov under the Apache License, Version 2.0. Supported by AZ.