Pergunta

I need to change the default favicon in Symfony 2, I have executed app/console assets:install web --symlink and made public my images folder inside the web directory. Check the following picture.

Web folder with favicon

In the base I have this by default:

<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />

I have tried to change that link to a lot of things containing the path to that public folder, but I have failed, the favicon does not load, besides I have read, that the favicon takes some time to show up (I don't know if this is completely accurate), but I don't know what is correct or what not. Can any one point me to the correct way?

Foi útil?

Solução

Your code

<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />

refers to web/favicon.ico, but your actual favicon file is located in web/bundles/teamerptransport/images. That's probably the reason why it doesn't work.

Why did you put the favicon in a bundle? Does it only apply to a part of your application? If the favicon should be displayed throughout the whole application, I'd suggest to place it directly inside the web folder (replacing the default one that comes with Symfony's Standard Edition).

This has the added benefit that some browsers will look for a favicon at http://www.yoursite.com/favicon.ico, so putting the file there will make sure those browsers will find it.

If you have any problems with no or old favicons being displayed in a browser, even though you're sure the URL is correct, make sure to clear your browser cache.

By the way, be sure to visit this favicon generator website (and read their FAQ) for some interesting tips on favicon files and browser support.

Outras dicas

Hi you should specify the good bundle !

{% image 
    @teamerptransport/Ressources/images/favicon.ico
%}
<link rel="shortcut icon" href="{{asset_url}}"/>
{%endimage%}

I think your image is in your bundle/ressources/public/images as recommanded

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top