gatsby: Can't change favicon
I want to change the favicon to a logo I am using for my website. I have this code in the head tag in my html.js file:
<head>
<meta charSet="utf-8"/>
<meta httpEquiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css"/>
<link href="https://fonts.googleapis.com/css?family=Libre+Franklin" rel="stylesheet"/>
<link rel="logo" href="favicon.ico" type="image/x-icon" />
{head.title.toComponent()}
{head.meta.toComponent()}
<TypographyStyle typography={typography}/>
<GoogleFont typography={typography}/> {css}
</head>
with this line to change the favicon:
<link rel="logo" href="favicon.ico" type="image/x-icon" />
But regardless of what path I use, I am unable to change the favicon. How can I change the favicon or where is the default beer logo favicon being set?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 33 (21 by maintainers)
This worked for me:
Is it OK to fix like this fix in
html.js?This is working well for me, except for the browserconfig.xml file generated by Real Favicon Generator.
Here’s what I’ve added to html.js:
This all works fine if I remove the two browserConfig lines. However, if I leave them in, the following error is thrown:
The
browserconfig.xmlfile is next to the images in the./static/faviconsfolder, so I’m not sure why the images are found, butbrowserconfig.xmlis not.Any idea what I’m doing wrong?
Yup! That’s exactly what the html.js file is for.
THIS WORKED.
In case it helps, at this point I use
gatsby-plugin-manifestinstead of manually importing favicons. Here’s a link to the docs.You just add a
favicon.pngto your project and add it to thegatsby-plugin-manifestsettings ingatsby-config. The plugin then creates all the favicon copies you need and injects the markup into your HTML.Much easier!
toComponentdoesn’t take arguments, you have to do<Helmet><html lang="en" /></Helmet>.Here’s my
gatsby-ssr.jsas an example of not using Helmet:@Vaestro I don’t believe you can add use
rel="logo". It should berel="icon"to indicate that this icon represents the site. You can see valid property values here