Reputation: 3
I am using react to build my web page. I placed my favicon.ico in my public/img folder. And the href of favicon.ico has set to /img/favicon.ico. But the favicon can not be load. After I check the favicon.ico request url in Chrome it is still http://localhost:3000/favicon.ico. I want the request url be http://localhost:3000/img/favicon.ico
This is my code for icon link
<head>
...
<link ref="icon" href="/img/favicon.icon" type="image/x-icon">
...
</head>
Very thanks
Upvotes: 0
Views: 697
Reputation: 155045
<head> <link ref="icon" href="/img/favicon.icon" type="image/x-icon"> </head>
There's a few things wrong with your above code:
<link rel="icon">
not <link ref="icon">
.favicon.ico
, not favicon.icon
, so correct the file-extension in the href
attribute: href="/img/favicon.ico"
./favicon.ico
for the benefit of pages that lack the <link rel="icon">
element, as most browsers will always check /favicon.ico
.type="image/x-icon"
(or image/vnd.microsoft.icon
) if the file actually is a Win32 .ico
file (which contains multiple images at different sizes). If the file is actually a single-frame .png
image or similar then use image/png
or whatever the type is.So you should have:
<link rel="icon" href="/img/favicon.ico" type="image/x-icon">
Upvotes: 0