Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Favicon in Ruby on Rails application [duplicate]

I put favicon.ico into /public/ folder and include the following code into layout page

<%= favicon_link_tag %>

But inspite of it, the icon doesn't display. What should I do?

like image 737
Alexandre Avatar asked Jun 17 '12 12:06

Alexandre


People also ask

What is difference between favicon favicon and site?

In this code favicon is a small image for a website that denotes the page Brand that can help to identify the original page. In other words, a favicon is a short icon or tab icon, or URL icon that contains 16x16 pixels or 32x32 pixels.

What is favicon optimization?

Favicon Optimization: Why Is It Crucial For SEO In 2022? A favicon is a small 16*16 pixel icon that serves as your website's branding. Its main purpose is to make it easier for visitors to find your page when they have multiple tabs open.


2 Answers

I have struggled with the same. This is what worked for me:

<%= favicon_link_tag 'favicon.ico' %>

and moving the favicon.ico to the /public/images directory.

Good luck!

like image 119
Anil Avatar answered Oct 25 '22 17:10

Anil


I don't know what favicon_link_tag is in your app but in general, there are two ways to create a favicon.

  1. Put your icon file in your app root directory (/public). In this case, you don't have to do anything in your code. (does not work in seamonkey, works in all other browsers I know)
  2. Place a link element in the code of your master view:

     <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/relative/path/to/file.ico" /> 
    
like image 40
toniedzwiedz Avatar answered Oct 25 '22 16:10

toniedzwiedz