Unable to set favicon using Jekyll and github pages

后端 未结 9 1844

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

相关标签:
9条回答
  • 2020-12-23 13:46

    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
    
    0 讨论(0)
  • 2020-12-23 13:49

    I use

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

    And I have favicon in folder images.

    0 讨论(0)
  • 2020-12-23 13:50

    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.

    0 讨论(0)
  • 2020-12-23 13:53

    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">
    
    0 讨论(0)
  • 2020-12-23 13:56

    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.

    0 讨论(0)
  • 2020-12-23 13:59

    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">
    
    0 讨论(0)
提交回复
热议问题