Skip to content

How to add a favicon with HTML link tags

Last checked 19 November 2026

The short version is one line of HTML. It goes in the head of your page, and it tells the browser where your icon file is.

Adding the faviconUpload the icon file to your siteAdd a link tag to the page headOpen your site and check the tab
Upload the file, then tell the page where it is.

The line to add

Google's instructions say to add a tag to the header of your home page.1 The "header" here means the head section of the HTML, the part before the visible page content.

Here's the simplest form:

<link rel="icon" href="/favicon.ico">

The rel part says what the file is for. The href part gives its address. Easy. The HTML standard says the icon keyword may be used with link elements.2

If you've made an SVG file as well, add a second line. Give it a type so the browser knows what it's getting:

<link rel="icon" href="/favicon.svg" type="image/svg+xml">

The sizes and formats page explains when you'd want each file.

Where the files go

Put the icon files at the top level of your site, next to your home page. Wikipedia's history of the format says the first favicons sat in a site's root directory.3 Starting there keeps your link tag short, because the address begins with a single slash.

If you use a website builder or a content management system, you may not edit the head at all. Your tool may have its own upload box for the icon instead. Use your own provider's help pages for that, since the screens differ from one to the next.

Do you still need the link tag?

You might get an icon without it. Browsers don't wait to be told: they ask for /favicon.ico at the top of the site by themselves.4

Still, add the tag. MDN says that providing explicit links protects you against changes to these conventions.4 It costs one line. It removes the guesswork.

Which pages need the tag

Put it on every page, which is easy if your site uses a shared template. Google's instructions only name the home page, so that one matters most for search.1 A shared template means you only edit the line once.

Using other hosts and absolute addresses

The href can be a short path like /favicon.ico or a full web address. Both work for Google, and the file doesn't even need to sit on your own site.1 Keeping it on your own site is simpler to look after.

If you use a Content Security Policy

Some sites send a security header called a Content Security Policy, which limits where files can load from. If your favicon doesn't load, MDN says to verify that the Content-Security-Policy header's img-src directive is not preventing access to it.4 Most small sites don't set one, so skip this if it's new to you.

After you publish

Open your site and look at the tab. If the old picture or nothing at all is showing, don't panic. There's a list of causes in why your favicon isn't showing.

Google is slower still, since its crawling can take several days or several weeks.1 The page on favicons in Google Search covers what to expect there.

Notes and sources

  1. Define a favicon to show in search results, Google Search Central
  2. HTML Standard, link type icon, WHATWG
  3. Favicon, Wikipedia
  4. <link>: The External Resource Link element, MDN Web Docs