Dark theme | Light theme

February 24, 2011

Grails Goodness: Set Application Wide Default Layout

Grails uses Sitemesh as the layout and decoration framework. Layouts are defined in the grails-app/views/layouts directory. There are several conventions Grails uses to determine which layout file must be applied. We can set a default layout for our application by setting the property grails.sitemesh.default.layout in grails-app/conf/Config.groovy. The value of the property maps to the filename of the layout. For example if we set the value to main then Grails will use grails-app/views/layouts/main.gsp.

Another way is to create a layout with the name application.gsp and save it in grails-app/views/layouts. Grails will use this layout if the layout cannot be determined in another way.