Favicons are this nifty little icons on the tab of your browser to help give a little personalized identity rather than the blank page one which is the default
This is one of the super fast things to fix yet I forget every time I build out a Rails app. Favicons can be created with a plethora of different sites. I’m old school and keep using DynamicDrive (http://tools.dynamicdrive.com/favicon/) as it has limited advertising and junk on the site.
The code block is super easy to remember…except when I need to remember it, so here it is:
<%= favicon_link_tag asset_path('image-name.ico') %>
Here are the steps to set up your favicon in your Rails app:
- Generate your icon
- Copy the icon to the
- Create the pointer in the HEADsection of your
app/views/layouts/application.html.erbfile as shown here:
Reload the server your server and you’re off to the races! Once you restart your app you should see your new icon appear. There may be some delay because some browsers (Chrome being the main culprit) believe in caching everything to save you time on loading. This creates problems because sometimes the cache invalidation takes a while when you legitimately want to see an update.
This will be the end result:
Hopefully this is helpful and saves you a little hunting for the solution.