How to add a Favicon to your site

The Complete Guide

profile
By Steve
March 8, 2023
How to add a Favicon to your site

You understand the importance of a great favicon and worked hard for it to stand out. It’s time to add it to your website.

Adding Favicon to the website depends on the type of website. Things change depending on the CMS usage or the Framework.

This is a complete guide to adding a favicon to your website. We’ll try to cover all CMS and frameworks.

Adding Favicons for Various Content Management System (CMS)

This section will cover various CMS and how to add Favicon is each one separately.

We’ll start with simple HTML websites and move our way to more popular ones.

HTML Websites

Here are the steps you need to follow to add code to an HTML website.

Add the Favicon Link

In the <head> section of your website's HTML code, add the following code to create a link to your Favicon:

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

Make sure to replace "favicon.ico" with the file name and path of your Favicon.

Verify Your Favicon

To verify the Favicon, open the website in any browser to check the functionality of a favicon.

If the Favicon doesn't appear, try clearing your browser's cache or checking that the file path to your Favicon is correct.

WordPress

Over 43% of all the websites on the internet use WordPress. The reason for its popularity is the functionality and drag-and-drop policy.

Here's how you can add a favicon to a WordPress website.

Prerequisite: Your logo must be ready in a suitable format. .PNG is usually the best with WordPress.

  • Navigate to your WordPress dashboard and go to Appearance > Customize > Site Identity. Here, you'll see the favicon option along with the logo. Add your favicon image here.

  • Save and Preview: Save your changes and preview your website to ensure the Favicon is displaying correctly.

  • Clear Your Cache: If the Favicon still doesn't appear, clear your browser's cache or try a plugin to clear the website's cache.

You can also upload the Favicon to the WordPress website directory. But the juice is not worth the squeeze. So, stick with this method.

Shopify

Shopify is the go-to CMS for E-commerce and those dropshipping websites. Adding a favicon is a no-brainer here.

Here’s how you do it.

  • In your Shopify dashboard, go to "Online Store" > "Themes" > "Customize" and select "Theme settings."

  • Here, you would see the "Favicon option." Upload the icon here. Save changes, and the Favicon is added to your website.

Other Popular CMS

There are myriads of CMS like Wix, Square Space, HubSpot, etc. Mentioning adding a favicon in each one would be too much repetition. So, here's a rule of thumb.

  • Go to the dashboard of your website and identify the layout/design section. Then go to the Logo section, and you'll see the Favicon or some call it browser icon.

  • Add your Favicon in there. Clear the browser cache, and your Favicon is ready for the world to see.

Different CMS might have different names for the pages, but the overall scheme is the same. Therefore, we have generalized it.

Adding Favicons for Different Frameworks

Moving to a little more fun stuff, this section will guide you on adding Favicon in popular frameworks.

Things might be tricky, but we would keep them simple and understandable.

NextJS

The prerequisite here is to get Favicon ready for adding to the Next.JS website. Then follow these steps.

  1. Place your favicon.ico file in the public folder of your Next.js project. You can either create a new favicon.ico file or use an existing one.

  2. In your Next.js project, make sure that you have a <head> component in your _document.js file.

  3. If you don't already have a _document.js file, you can create one in the pages directory.

  4. Inside the _document.js file, import the Head component from next/document.

  5. Then, add the following code inside the Head component: <link rel=" icon" href="/favicon.ico" />

  6. Save the _document.js file and restart your Next.js server. Your Favicon will be ready.

Alternatively, you can use the Real Favicon Generator to create a favicon inlined with a safari-SVG image and other formats.

Then, place the generated code in the public folder of your Next JS project, and it all will be good.

Laravel

Here’s how you can add a favicon in Laravel.

  • Place your favicon file in the public folder of your Laravel project; Create New or use an existing one.

  • In the <head> section of your main blade template file (usually resources/views/layouts/app.blade.php), add the following code:

<link rel="shortcut icon" type="image/x-icon" href="{{ asset('favicon.png') }}">
  • This code uses the asset() helper function to reference the favicon.ico file in the public folder.

  • Save the changes to your template file. Clear the Laravel application cache by running the following command in your terminal:

php artisan cache:clear
  • Refresh the website, and your Favicon is added.

Django

Here’s the step-by-step guide for adding favicons to your Django Project.

  • Place your favicon file in the static folder of your Django project.

  • Then, in your base template file (usually base.html), add the following code to the <head> section:

{% load static %}
<link rel="icon" href="{% static 'favicon.png' %}" type="image/x-icon">
  • Make sure the Django.contrib.static files app is included in your INSTALLED_APPS setting in the settings.py file.
    Run the following command in your terminal to collect the static files:

python manage.py collectstatic
  • Refresh your website in the browser, and you should see the Favicon displayed in the tab.

Nuxt JS

Here’s how you can add a favicon to a Nuxt JS.

  • Add the favicon file in the static folder of your Nuxt.js project.

  • In your nuxt.config.js file, add the following code inside the head object: 

head: {
  link: [
    { rel: 'icon', type: 'image/x-icon', href: '/favicon.png' }
  ]
}

Save the changes to your nuxt.config.js file. Then Restart your Nuxt.js server.

  • Your website's Favicon is now visible.

Final Thoughts

At superdense, all types of websites get bookmarked. And Favicons are the way to mark your presence.

Although much thought goes into creating favicons, not much goes into adding them to the website.

Therefore, many people struggle with adding favicons to their websites.

We tried to simplify this concept for non-techies and programmers. Hopefully, this helps.

Happy Bookmarking! ✨