I found a lot of entries in my logfile, which indicate that somebody tried to load /favicon.ico and similar files
GET - /favicon.ico
GET - /apple-touch-icon.png
GET - /apple-touch-icon-precomposed.png
I read a lot about this issue online, but I can't get rid of it. Here is what I trued. First I added the following to my head tag
<link rel="shortcut icon" href="/static/favicon/favicon.ico" type="image/x-icon">
However, even though I provide this information in my header, there seem to be browsers out there which don't care about it and still call /favicon.ico?
So I thought just putting the ico file at root and be done with it, but it does not seem to work? If I call
http://localhost:5000/static/favicon/favicon.ico
I get to the icon, but
http://localhost:5000/favicon.ico
Does not work (gives 404)? I cleared my cache and tried it with Chrome and Safari, but I get 404 in both cases? I am really at a loss here. If I move the image in the static folder and call
http://localhost:5000/static/favicon.ico
it works, but the root folder doesn't? What am I missing here?
By default, the flask will only serve files on the /static endpoint. You can add a custom view to handle the default /favicon request.
The flask documentation has some more information on this subject:
https://flask.palletsprojects.com/en/1.1.x/patterns/favicon/
import os
from flask import send_from_directory
#app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon')
I ran into a very similar problem. I do not have the necessary points to add a comment to the answer yet. So I'll do it using "Your answer". For those who need a much more specific answer on how to use url_for () here is one way to do it.
<!-- Adding a favicon icon to Flask app -->
<!-- SEE: https://favicon.io/favicon-converter/-->
<link rel="shortcut icon"
href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="apple-touch-icon"
sizes="180x180"
href="{{ url_for('static', filename='apple-touch-icon.png') }}">
<link rel="icon"
type="image/png"
sizes="180x180"
href="{{ url_for('static', filename='favicon-32x32.png') }}">
<link rel="icon"
type="image/png"
sizes="16x16"
href="{{ url_for('static', filename='favicon-16x16.png') }}">
<link rel="manifest"
href="site.webmanifest">
To generate the necessary files use the following link: https://favicon.io/favicon-converter/ All files were copied into the /static directory.
Related
I'm building a website in HTML, and hosting it via GitHub Pages. You can take a look of it here: http://marcuscodes.me/
It has previously shown normally with this code:
I also tried using favicons:
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico?">
I have tried adding a ? to my path as shown here:
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico?">
However, it still does not show.
I have tried these steps:
Refreshing browser cache
Using different browser
using different device
You can view the full source code here. https://github.com/inkthought-labs/website
Thanks for any help!
In your index.html, you used this to supposedly create the favicon:
<link rel="icon" href="https://i.ibb.co/SBX2vY1/inkthoughtinvis.png">
However, you forgot the type attribute. It should be:
<link rel="icon" type="image/png" href="https://i.ibb.co/SBX2vY1/inkthoughtinvis.png" />
Additional note: If permitted by copyright licenses, it is best that you download the image to your local storage and then set the location into the href attribute. In the scenario that the website host removes the image, it will not display.
<link rel="icon" type="image/png" href="https://i.ibb.co/SBX2vY1/inkthoughtinvis.png" />
I use realfavicongenerator.net to generate favicon.ico and all the other files required nowadays. This is a lot of files (over 10) and as they recommend, I keep them in the site root. This looks quite messy and makes it slower to see important stuff such as my configuration files amongst them.
What I'd like to do is to keep them all in a _favicon subfolder, but have a Jekyll configuration option that copies the contents of the subfolder to the root of _site when publishing. Is there an option that'll do this?
After encountering the same problem. I did some digging around and finally decided to write a ruby plugin for this. It would be a better solution that storing some of your files in an icon folder but having to keep other files like browserconfig.xml and favicon.ico in the root because of Yandix. What this will give you is a way to keep all the files in one place and copy them to the _site folder on build. <-- this is what was asked for. Not some ""hacky"" solution.
Make a folder in root called _plugins.
Jekyll automatically uses plugins from this folder during build. Name the file something like copy-my-files.rb
So: ./_plugins/copy-my-files.rb
ruby plugin code:
#!/usr/bin/env ruby
require 'fileutils'
module Jekyll
Jekyll::Hooks.register :site, :post_write do |post|
Dir.glob('_favicon/*.*') do |file|
sourcePath = file
outputPath = File.join('_site', File.basename(file) )
FileUtils.cp(sourcePath, outputPath)
end
end
end
What this will do is every time the site gets built it will copy all the files from _favicon into the _site folder.
Include the generated links in _includes/head.html
or
Write a file that contains all the links called favicons.html
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta nam
e="theme-color" content="#ffffff">
If you made a separate file called favicons.html include it in your head with this: {% include favicons.html %}
{% include favicons.html %}
So this will work because all of the files in _favicon fill get copied. The site.wbmanifest, manifest.json and all the png icons and what not.
Like another post has said you can break this out into its own html partial include {% include favicons.html %} and you would then link includes/favicons.html in your header.html file.
I use a similar favicon generator, but locate the generated files in a subfolder to keep things clean, then I load them with a partial {% include favicons.html %} and in includes/favicons.html:
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="{{ 'assets/favicons/apple-touch-icon-57x57.png' | absolute_url }}" />
....
Real question is, do they really need to be on the root folder? I don't think so. These are the reasons they gave to put them at root and how to deal with them:
Internet Explorer looks for favicon.ico at the root of the web site.
Granted: this is because we ask you to not declare favicon.ico.
Then you just need to keep one favicon at root, and that is favicon.ico, all the rest can be in a subdirectory.
iOS devices look for files such as apple-touch-icon-144x144.png at the
root of the web site, as described by Apple. This issue can be
mitigated by declaring the icons in the HTML code (this is necessary
for Android anyway), but following Apple conventions is probably the
best move.
Explicitely declaring all favicons paths works, the ones that would be loaded in the partial file, as stated by the recommended Apple's page:
To specify an icon for a single webpage or replace the website icon
with a webpage-specific icon, add a link element to the webpage, as
in:
By default, Internet Explorer 11 looks for browserconfig.xml at the
root of the web site.
Just keep browserconfig.xml at root and refer to favicons inside it to the proper path.
Several services, such as Yandex, look for favicon.ico in the root
directory.
Same as first reason, just keep favicon.ico at root.
If you still want them at root, use wrappers for main Jekyll commands: build and serve instead of using them directly:
For example for build:
mkdir _finalsite
cp -r * _finalsite/
cp _favicons/* _finalsite/
jekyll build -s _finalsite
Good night, i have a page mounted on github pages:
https://ludicultura.github.io/ludiweb/
If you open that link the favicon works perfectly, but i buy a domain on goDaddy so i can redirect that page, masking it with my domain:
http://ludicultura.com/
and there the favicon it doesn't work.
(Both of them links are up, so you can check them.)
I tried the option of adding a "?" to the end of "href"
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?">
And algo changing my image to png:
<link rel="shortcut icon" type="image/png" href="/favicon.png"/>
But nothing works, what is happening?
Source and records of the repository and all the changes:
https://github.com/ludicultura/ludiweb
For ludicultura.github.io/ludiweb/, change your favicon url to <link rel="shortcut icon" type="image/x-icon" href="{{ site.baseurl }}/favicon.ico">.
But framing ludicultura.github.io/ludiweb/ in ludicultura.com is not a good practice.
You'd better setup your custom domain correctly after reading this documentation on github pages.
I am trying to set a favicon.ico for my github page, but it doesn't work. When I serve it locally I see the standard "empty" favicon and when I push it I see the facebook icon. Why is it so? I have the right favicon.ico in the root directory of my project and I added the line
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
to the relevant default.html. You can see the sources here: https://github.com/drorata/drorata.github.io
I cloned your project from GitHub to take a look at it. After serving it using Jekyll, the favicon did not display, as you noted.
I did some quick testing by converting the favicon file to be a .png rather than a .ico file and changing the favicon declaration to the following, and that was able to get it to display the favicon.
<link rel="shortcut icon" type="image/png" href="/favicon.png">
I tried getting the favicon to work while keeping the .ico file format, and was unable to do so at first. However, I did some quick searching and came across this question, favicon not displayed by Firefox.
In that question the asker had a similar issue with the favicon not showing, and was eventually able to come up with a quick fix by adding a ? to the end of the link to the favicon file in the favicon declaration. I attempted this and it worked. Here is what the favicon declaration would be:
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?">
Either of those two methods seem to be able to fix your issue. Personally I'd recommend using the first method, whereby you convert the image to a .png file, as it seems a bit simpler and less hacky.
However, if you want to keep the file as a .ico file then you should read over the question that I linked to before you attempt the second method, as the accepted answer for the question differed from that solution. Also I'm not sure as to why the second method works, and it does seem a little bit hacky.
I believe, currently, the correct way to do this is:
<link rel="shortcut icon" type="image/png" href="{{ "/favicon.png" | prepend: site.baseurl }}" >
Assuming you are using a png. The following also worked for me with a .ico instead of .png:
<link rel="shortcut icon" type="image/x-icon" href="{{ "/favicon.ico" | prepend: site.baseurl }}" >
I was working with Chrome on Linux. Neither Excalibur Zero's answer or Ribtoks answer worked for me.
Quick solution
Leave the slash out to make the href address relative.
For example:
Change
<link rel="shortcut icon" type="image/png" href="/favicon.png">
to:
<link rel="shortcut icon" type="image/png" href="favicon.png">
In my github pages site this works perfectly.
Explanation
Use my site https://hustlion.github.io/spanish-cards/ as an example:
When you use <link rel="shortcut icon" type="image/png" href="/favicon.png">, the icon address will be https://hustlion.github.io/favicon.png, because the root of the site (as specified by the slash in /favicon.png) is https://hustlion.github.io/.
However, when you use <link rel="shortcut icon" type="image/png" href="favicon.png">, this is relative to the path https://hustlion.github.io/spanish-cards/, so the icon address will be resolved properly as https://hustlion.github.io/spanish-cards/favicon.png.
Notes
This path issue happens especially when you are using github pages for your specific repository.
I use
<link rel="shortcut icon" type="image/x-icon" href="{{ site.baseurl }}/images/favicon.ico" >
And I have favicon in folder images.
Nothing above worked for me, but the steps in this vid (assuming the minima theme) did.
1) Add _includes directory to your project root
Terminal: find _includes/head.html by typing bundle show minima
Copy _includes/head.html from finder into your project root
2) Modify _includes/head.html to include favicon link
The following works for me: <link rel="shortcut icon" type="image/png" href="/favicon.png">
Important: the / in front of /favicon.png matters. Without the /, your website root will have your favicon but no other endpoints will.
3) Add the jekyll-seo-tag plugin to your _config.yml. It should look something like this:
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
- jekyll-seo-tag
according to documentation:
1) put favicon.ico file into assets/images folder of jekyll project as assets/images/favicon.ico
2) create a _includes/head_custom.html file if not yet exists
3) add needed overriding content:
<link rel="shortcut icon" type="image/x-icon" href="{{ site.baseurl }}/assets/images/favicon.ico">
Done.
I got it to working using:
<!-- Add favicon -->
<link rel="shortcut icon"
type="image/png"
href="{{ '/favicon.png' | relative_url }}" >
Notes on the snippet:
PNG format for the favicon,
a relative URL in the HTML head tag (in minimia this is head.html).
Adding relative_url tells Liquid to prepend the url and baseurl to the given path.
Just in case someone will be looking for this. Both approaches didn't work for me. But when I appended the site.url, it worked
<link rel="shortcut icon" type="image/png" href="{{site.url}}/favicon.png">
In my case, I had to add the favicon.ico file to the assets folder and reference it as follows:
<link rel="shortcut icon" type="image/x-icon" href="assets/favicon.ico">
I couldn't get the images to display and I use markdown for my posts, appending what worked for me so that others may benefit.
![Description of the image]({{ site.baseurl }}/assets/images/image.png)
This works both locally and on github pages as well
New to web dev. I have a favicon that works locally but doesn't want to behave on server. The following is my favicon tag in the head tag:
<link rel="icon" type="image/png" href="../favicon/microphone-icon-192783/microphone-icon-16-192783.ico"/>
Am I missing something for the server?
Old question but for anyone who experienced the same issue as me..
Spent about an hour trying to figure out why i was experiencing the same problem. Clearing history, updating code didnt work.
Restarted chrome browser and worked straight away ahah
Just upload the favicon to your root directory and give it the name "favicon.ico". By putting it in your root directory, you'll have a default favicon for all the pages in your domain.
Depending on the browser you use, you can add the following two lines into the head section of your pages.
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
Make an PNG file and set it as the favicon in an index.html page so the cache is overwritten:
<html><head><link rel='icon' type='image/png' href='favicon.png' /></head></html>
It works.
Try uploading the icon somewhere on the web, and link it to that image url. I remember having issues with accessing a background-image on local machine, but if I was trying to link it from the web, I had no problems. I think this should do the trick. Didn't use it though.
You could try removing the ../ like this.
<link rel="icon" type="image/png" href="favicon/microphone-icon-192783/microphone-icon-16-192783.ico"/>
but could we have the file path according to the server root if this doesnt soleve it? its easier to find a solution that way :)
You could try <link href="/favicon.ico" rel="shortcut icon">, where '/' stands for absolute root path... (root direcory)
Make sure the folder having the icon image on the server has the permissions set to 0755.
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
If this still won't update the favicon on the webpage, RESTART THE BROWSER