无法使用Jekyll和github页面设置favicon [英] Unable to set favicon using Jekyll and github pages

查看:162
本文介绍了无法使用Jekyll和github页面设置favicon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的github页面设置 favicon.ico ,但它不起作用。当我在本地提供服务时,我会看到标准的空白图标,当我推送它时,我会看到Facebook图标。为什么这样?我在项目的根目录中有正确的 favicon.ico ,并且添加了行

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

添加到相关的 default.html 中。你可以在这里看到来源: https://github.com/drorata/drorata.github.io

to the relevant default.html. You can see the sources here: https://github.com/drorata/drorata.github.io

推荐答案

我从GitHub克隆你的项目来看看它。正如您注意到的那样,使用Jekyll提供的favicon图标并没有显示出来。

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.

我做了一些快速测试,将favicon文件转换为 .png 而不是 .ico 文件,并将favicon声明更改为以下内容,并且能够显示favicon。

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

我试着让图标工作,同时保持 .ico 文件格式,并且一开始就无法这样做。但是,我做了一些快速搜索并发现了这个问题, favicon不会在Firefox中显示

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.

在这个问题中,提问者与favicon没有显示相似的问题,并最终能够通过在favicon声明中的favicon文件链接的末尾添加一个来快速解决问题。我试过这个,它工作。以下是favicon声明的内容:

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

这两种方法中的任何一种似乎都能解决您的问题。就我个人而言,我建议使用第一种方法,即将图像转换为 .png 文件,因为它看起来更简单一点,也更简单。

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.

然而,如果您想将文件保存为 .ico 文件,那么您应该在尝试之前仔细阅读我链接的问题第二种方法,因为问题的接受答案不同于该解决方案。另外,我不确定为什么第二种方法能够工作,而且看起来有点乱。

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.

这篇关于无法使用Jekyll和github页面设置favicon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆