Unable to set favicon using Jekyll and github pages - html

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

Related

My favicon for my HTML website does not show

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" />

Github Pages website favicon not showing

I'm hosting a website using Github Pages. I connected Cloudflare to the website because of SSL. When i finally added favicon.ico to my website and the following code in <head> to make the favicon show up, it still doesn't show up. What can i do?
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
(english is not my native language)
Edit: Seems like other people can see the favicon, except me. But why?
I have had the exact same problem. I was able to solve it by including a ? in the end.
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico?">
I am not exactly sure why adding in ? works but the code below does not.
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico?">
Adding a question mark at the end of the path is one workaround.
<link rel="shortcut icon" type="image/png" href="coin.png?">
Try also using a URL from a site that has the image, it might work.
<link rel="shortcut icon" type="image/x-icon" href="./Images/favicon.ico?">
if you did something like this , then go to your github.io page and hard reload.
You can use
ctrl/cmd + shift + r
to hard reload the page . That will clear your cache .
If you've deployed a project created using npm to Github Pages and if your build files are in a separate sub-directory, you'll have to define the path to the favicons like this (note the dot).
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png">
Add the icon path correctly
<link rel="icon" href="./favicon.ico"/>

Favicon not working when redirecting github page with mask (my own domain)

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.

Why is my favicon not working on server but is working locally?

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

Add favicon to JSF project and reference it in <link>

How do I add a favicon to a JSF project and reference it in <link> element?
I tried as below:
<h:head>
<link rel="icon" type="image/x-icon" href="images/favicon.ico"/>
...
</h:head>
However, it didn't show any favicon.
A relative href is relative to the current request URI. Likely it resolved to an invalid URL. You need to prepend with the context path so that it becomes relative to the domain root.
Also, the rel has better to be shortcut icon to get it to work in older browsers too.
In case of using an .ico file, you also need to ensure that it's a real .ico file and not some .bmp renamed to .ico. You can generate one here based on several image formats. You can however also just use a .png or .gif file.
All in all, provided that the file is located in
WebContent
|-- images
| `-- favicon.ico
:
then this should do it:
<link rel="shortcut icon" type="image/x-icon" href="#{request.contextPath}/images/favicon.ico"/>
If you've however placed it as a JSF resource in the /resources folder as follows
WebContent
|-- resources
| `-- images
| `-- favicon.ico
:
which would make it accessible by <h:graphicImage name="images/favicon.ico">, then this should do it:
<link rel="shortcut icon" type="image/x-icon" href="#{resource['images/favicon.ico']}"/>
See also:
Wikipedia - Favicon
How to reference CSS / JS / image resource in Facelets template?
I used the following and it works in both IE and Chrome
<link rel="shortcut icon" href="#{resource['images/favicon.ico']}" type="image/x-icon" />
Since JSF uses the resources as a container for storing the image file folder, you can do the following;
<link rel="shortcut icon" type="image/x-icon" href="#{request.contextPath}/resources/images/favicon.ico"/>
As a side note, I always include both of these when referencing a favicon:
<link rel="shortcut icon" type="image/x-icon" href="https://a.staticimageserver.com/img/favicon.ico" />
<link rel="icon" type="image/x-icon" href="https://a.staticimageserver.com/img/favicon.ico" />