How to easily add a favicon to your Rails App ✨

ritumka

Margarita Potylitsyna

Posted on November 20, 2024

How to easily add a favicon to your Rails App ✨

1. Add the Favicon File:

  • Go to https://www.freepik.com. In the searching options choose icons and type the key word
    Download the icon

  • Download the icon you like in .png format

  • Rename the file to favicon.png

  • Place the file in your app’s app/assets/images directory

2. Add a Link to the Favicon in HTML Head:

  • Open the app/views/layouts/application.html.erb file
  • Add a link tag in the <head> section to specify the favicon: <%= favicon_link_tag 'favicon.png', type: 'image/png' %> Add a link tag

3. Clear Cache:

  • Browsers often cache favicons, so you may need to clear your cache or perform a hard refresh to see the new favicon.

4. Restart the Server:

  • Restart your Rails server to ensure that all changes are picked up.

Once done, your Rails app should display the favicon on the browser tab! 🤩

Favicon on the browser tab

💖 💪 🙅 🚩
ritumka
Margarita Potylitsyna

Posted on November 20, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related