문제

Trying to add a favicon to my rails app, but doesn't seem to be working locally. Heres my code

Aplication.html.erb (in the head section)

<%= favicon_link_tag '/favicon.ico' %>

Note: Favicon has been saved within my asset/images folder and the icon is 64x64 pixel

Is there anything thats been done wrong here?

Thanks in advance

도움이 되었습니까?

해결책

I think the address should be without the slash:

<%= favicon_link_tag 'favicon.ico' %>

다른 팁

The proper use of favicon_link_tag is the immediate solution:

<%= favicon_link_tag 'favicon.ico' %>

However, a single favicon.ico can only address most desktop browsers. Mobile browsers can't cope with it but need higher resolution icons, like the Touch icon for iOS devices. You can get support for all browsers with RealFaviconGenerator:

  • Go to RealFaviconGenerator and submit your picture. You can edit your icons platform-per-platform (Android, iOS...).
  • When the icons are ready, follow the instructions.

The instructions are clear enough to setup the favicon, so there will be no path issue, no "extra slash" issue, etc.

Full disclosure: I'm the author of this site.

Using rails 4.2.3, in my /public folder there was already a favicon. I simply replaced that and DID NOT ADD <%= favicon_link_tag 'favicon.ico' %>. Worked perfectly.

Weird thing is I first tried with the favicon_link_tag and that somehow prevented the favicon from showing up.

The proper use of favicon: add this <%= favicon_link_tag(source='favicon.ico')%>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top