Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails : how to change site favicon?

Tags:

favicon

grails

I tried to replace favicon.ico in /web-app/images/ folder but it doesn't work : my site still has the usual Grails favicon. What do I need to do more?

like image 529
Rob Avatar asked Nov 25 '13 09:11

Rob


People also ask

How do I set a favicon location?

To add a favicon to your website, either save your favicon image to the root directory of your webserver, or create a folder in the root directory called images, and save your favicon image in this folder. A common name for a favicon image is "favicon. ico".

How do I change the favicon in CSS?

You can't set a favicon from CSS - if you want to do this explicitly you have to do it in the markup as you described. Most browsers will, however, look for a favicon. ico file on the root of the web site - so if you access http://example.com most browsers will look for http://example.com/favicon.ico automatically.

How do I create a dynamic favicon?

To change favicons dynamically, we will create two javascript functions, to change favicons GeeksforGeeks and Technical Scripter respectively. We will assign a constant variable and get them by the favicon Id with the getElementById() function. After that, we will create 2 functions and assign two buttons for that.


3 Answers

With the grails assets plugin you must use:

<head>
    ...
    <asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
</head>
like image 85
mpccolorado Avatar answered Oct 21 '22 04:10

mpccolorado


try to change views\layout\main.gsp

<html>  
    <head>  
        <title><g:layoutTitle default="Grails" /></title>  
        <link rel="stylesheet" href="${createLinkTo(dir:'css',file:'main.css')}" />  
        <link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" />  
        <g:layoutHead />  
        <g:javascript library="application" />                  
    </head>  
    <body>  
        <div id="spinner" class="spinner" style="display:none;">  
            <img src="${createLinkTo(dir:'images',file:'spinner.gif')}" alt="Spinner" />  
        </div>      
        <div class="logo"><img src="${createLinkTo(dir:'images',file:'grails_logo.jpg')}" alt="Grails" /></div>     
        <g:layoutBody />        
    </body>     
</html>

and comment

<link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" /> 

or clean your browser's cache. ;-)

like image 43
Franklin Fu Avatar answered Oct 21 '22 04:10

Franklin Fu


Put favicon.ico file to PROJECT/grails-app/assets/ folder,

add to UrlMappints

class UrlMappings {

    static mappings = {
      ......
      "/favicon.ico"  (uri: "/assets/favicon.ico")
    }
}
like image 42
Yu Jiaao Avatar answered Oct 21 '22 05:10

Yu Jiaao