Update:
I recently (in 2023) ran into a similar issue where I could not render my favicon.ico file in google chrome.
Notice that the syntax rel="shortcut icon"
is not to be used anymore.
Instead, you should be using: rel="icon"
.
To solve the issue, assuming your .ico
file is suitable, there are two things you may want to check:
- Try renaming the
favicon.ico
- Check your file structure
Now, a solution to this issue is to rename the favicon.ico
file.
For instance, this html code with the filename favicon.ico
does not render the favicon in Chrome:
<link rel="icon" href="/static/favicon.ico" type="image/x-icon" />
But simply renaming the file to favicon2.ico
actually works:
<link rel="icon" href="/static/favicon2.ico" type="image/x-icon" />
If you are not getting and error message, your file structure is probably ok.
The above code works when added into the file layout.html
, with this file structure:
├── app
│ ├── __init__.py
│ ├── static
│ │ ├── favicon2.ico
│ │ └── styles.css
│ └── templates
│ ├── index.html
│ ├── layout.html
...
In case both the html file and the .ico
files are in the same folder, you should change href to this instead:
<link rel="icon" href="/favicon2.ico" type="image/x-icon" />