Tuesday, January 7, 2014

How to add a sitemap in my Grail war application ?

Today, I decided to add a sitemap for my new Grail website.First of all, I generated one by using online sitemap generator. For example, there is the following http://www.xml-sitemaps.com . You have to put your website url and it will produce sitemaps files (xml, zip, and so on). Here is an example of sitemap :
<?xml version="1.0" encoding="UTF-8"?>
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->


Then, I download the file sitemap.xml and I paste it in the web-app directory of my Grails application.After that, I modified my BuildConfig.groovy like the following :

grails.war.copyToWebApp = { args ->
    fileset(dir:"web-app") {
        include(name: "js/**")
        include(name: "css/**")
        include(name: "fonts/**")
        include(name: "images/**")
        include(name: "WEB-INF/**")
        include(name: "sitemap.xml")
To finish, I run grails war command and deploy it in Tomcat web container.
That's all. Now, your sitemap is available in http://your.app.com/sitemap.xml and you can add for example to google webmaster tools.

Thursday, January 2, 2014

Grails meta tag and internationalization

If you used Grails with internationalization, you knew the use of <g:message> but how to use it in Meta tag content description ?
Here is how :

<meta name="description" content="${message(code:'index.goal')}" />