Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Favicon with GitHub Pages

I'm hosting a few sites with GitHub Pages (User and Project Pages), but they are not displaying their favicons (in the browser).

<link rel="shortcut icon" type="image/png" href="/favicon.png">

Is the problem that GitHub displays the site with <frameset>? I know it's possible to display favicons (at least with Jekyll), but can I display a favicon on it's own?

like image 571
Rokin Avatar asked Jan 27 '16 12:01

Rokin


People also ask

How do I add a favicon to all pages?

To add a favicon to your website, either save your favicon image to the root directory of your webserver, or create a folder in the root directory called images, and save your favicon image in this folder. A common name for a favicon image is "favicon.ico".

Can I use a PNG as a favicon?

A favicon can actually be either a PNG, GIF, or ICO file. However, ICO files are typically used more than others as the file size is smaller and it is supported in all major browsers. PNGs are used more commonly for IOS, Android, and Windows 10 devices.

Should favicon be PNG or SVG?

SVG is a great way to reduce image size for images that aren't supposed to be bitmaps in the first place; for many logos the resulting file will be much smaller than a PNG. With just three PNG images in this minimum set, you can use advanced tools to optimize their size.


4 Answers

Yes, you can.

Put this into the head part of your webpage:

 <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">

It is important to not put the slash before the favicon.ico part. Put the favicon.ico file in your repository's home directory.

like image 142
Dmitry Pleshkov Avatar answered Oct 23 '22 08:10

Dmitry Pleshkov


It also works with favicon.png

  <head>
    ...
    <link rel="shortcut icon" type="image/png" href="favicon.png">
  </head>

The only problem is the slash / in "/favicon.png"

However this does not work for sub-pages!

The link should look like this - so you have the favicon on every page:

<link rel="shortcut icon" type="image/png" 
      href="{{ "/assets/images/favicon.png"  | absolute_url }}">

The resolved URL looks like: https://pme123.github.io/scala-adapters/assets/images/favicon.png

This expects the favicon.png in assets/images folder of your Jekyll project.

like image 44
pme Avatar answered Oct 23 '22 06:10

pme


I used

 <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">

as well as

 <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">

or

 <link rel="shortcut icon" type="image/x-icon" href="{{site.url}}/favicon.ico">

None of that worked. Finally I got it working by

 <link rel="shortcut icon" type="image/x-icon" href="favicon.ico?">

in fact, seems that any of the above solution with an extra "?" at the end will do the trick.

like image 29
wooohooo Avatar answered Oct 23 '22 08:10

wooohooo


<link rel="shortcut icon" type="image/x-icon" href="./Images/favicon.ico?">

look carefully i added a "?" at the end of the href. 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 . After that I am hopeful that you will see the fav-icon.

like image 2
Zahin Uddin Avatar answered Oct 23 '22 08:10

Zahin Uddin