Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

favicon not working in angular application

This is below code which is for a custom favicon

 <link rel="shortcut icon" sizes="16x16" href="favicon-16x16.png" type="image/png" />

in angular.cli

"assets": [
        "assets",
        "favicon-16x16.png"
      ],
  • It's working for this URL(main menu) : http://localhost:4200/maintenance

  • But it's not working for this URL(Sub Menu): http://localhost:4200/maintenance/colors

EDIT:

Also it's not working with full favicon URL href="../src/favicon-16x16.png"

Folder structure :

enter image description here

I have tried with putting all type of URL's from my old question : Different between ./ , ../ , ../../ , ~/ on file path(URL) in asp.net

But it doesn't help me.

like image 638
Ramesh Rajendran Avatar asked Aug 09 '17 08:08

Ramesh Rajendran


People also ask

Why is the favicon not working?

When you add a favicon to your site, it may not show up since your browser has 'saved' your site as one without a favicon. You need to clear the cache in your browser or use a different browser.

What are favicons Chrome?

A favicon, short for "favorites icon," is a small graphic you can associate with your website for display in browsers like Internet Explorer, Firefox, Mozilla, Opera, Safari, iCab, and AOL Explorer.


2 Answers

Add image inside assets folder and update below path in index.html

<link rel="icon" href="assets/favicon.png" type="image/png">
like image 168
Pranay Kharsamble Avatar answered Oct 03 '22 11:10

Pranay Kharsamble


Consider the fact that favicons are always heavily cached. Even window reload with cache cleaning may not help you. Try to add a get param to the favicon path, for example:

<link rel="icon" sizes="16x16" href="some-path/favicon-16x16.png?v=2" type="image/x-icon" />
like image 45
Mike Kovetsky Avatar answered Oct 03 '22 10:10

Mike Kovetsky