Adding robots.txt to your Grails app

I just wanted to add a robots.txt file to Groupie, easy enough you say, as a matter of fact yes it is :-)

What I did was to add the following line to UrlMappings.groovy in the Configuration folder:-

"/robots.txt" (view: "/robots")

then created a robots.gsp file in the Views and Layouts folder that looks something like this:

<%@ page contentType="text/plain;charset=UTF-8" %>User-agent: *
Disallow: /blah/
Note no new-line before User-agent: * here is to remove the blank line left by the <%@ page...%> in the file.

Now when you go to you get a robots.txt, simple.

Copyright © nerdErg Pty Ltd 2012 ABN 20 159 294 989