Search code examples
ruby-on-railsruby-on-rails-4favicon

Rails 4: favicon not showing


My favicon just won't show, in Chrome or Firefox. This is how I am rendering it in the <head> section:

<%= favicon_link_tag 'favicon.ico' %>

It is located in public/images.

This is the produced HTML:

<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">

Opening the link in my browser shows the icon correctly.


Solution

  • The favicon is not handled by the asset pipeline when its in the public folder, and this can cause caching problems.

    See here: How to add favicon in rails 3.2 and Clear the cache from the Rails asset pipeline.

    Use the favicon_link_tag and place the .ico file in /app/assets/images/ to get it into the asset pipeline.

    If it still doesn't work after that, try clearing your browser cache, your rails cache, and restarting your rails server.