Home > Back-end >  Why is the favicon only shown in the root page?
Why is the favicon only shown in the root page?

Time:03-09

I have a react app and a favicon icon in the folder src. It is only shown for the root path, the other pages cannot find it. In the developer tools, it show a wrong path for a subpage, it tries to get the favicon from http://localhost:3000/faq/src/favicon.ico

index.html

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

it works for http://localhost:3000/ but not for

http://localhost:3000/faq

CodePudding user response:

You should put your favicon under your public directory

|
 `--- public
     |
      `--- favicon.ico

And then refer to it in your index.html file like this:

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