【问题标题】:How to fix: favicon only showing up on the homepage of my website [duplicate]如何解决:网站图标仅显示在我网站的主页上 [重复]
【发布时间】:2019-09-21 12:51:37
【问题描述】:

我的网站图标只显示在我网站的主页上。

它位于我在 github 上的 repo 的根目录中,我已将以下几行分别添加到 head.html_config.yml 文件中。

我尝试了多个路径和文件名。检查网站上其他页面上的源代码时,它似乎将相对路径与最后的/favicon.png 链接起来。

主页来源指向网站图标。

<link rel="shortcut icon" type="image/png" href="favicon.png">
plugins:
   - jekyll-feed
   - jekyll-seo-tag

这是我的head.html 文件:

<head>
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   {%- seo -%}
   <link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
   <link rel="shortcut icon" type="image/png" href="favicon.png">
   {%- feed_meta -%}
   {%- if jekyll.environment == 'production' and site.google_analytics -%}
     {%- include google-analytics.html -%}
   {%- endif -%}
 </head>

我的网站图标不应该显示在每个子页面上并张贴在网站上吗?

目前只在首页显示,其他页面不显示。

这是我的回购: https://github.com/Redm0nd/redm0nd.github.io

网页是www.dylanredmond.me

【问题讨论】:

    标签: html css jekyll favicon


    【解决方案1】:

    可以通过在 favicon.png 之前添加斜杠来解决此问题,如下所示。

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

    没有斜线,favicon.png 是相关路径,所以它是从以下路径加载的,但它不存在。

    http://www.dylanredmond.me/jekyll/update/2019/04/30/favicon.png

    【讨论】:

    • 嗯。它适用于没有前导斜杠的主页,但不适用于其他页面。带有前导斜杠的它不适用于任何页面...我的网站图标位于子文件夹assets/favicon/
    猜你喜欢
    • 1970-01-01
    • 2020-06-05
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 2020-07-25
    • 2016-11-20
    • 2021-12-21
    • 1970-01-01
    相关资源
    最近更新 更多