jekyll GitHub 页面未加载资产
jekyll GitHub Page page not loading assets
我有一个 GitHub 托管 https://waltershub.github.io the repo is https://github.com/waltershub/waltershub.github.io
站点在本地正确构建所有资产 css 但在托管版本 none 上显示
控制台中的错误是:
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (font-awesome.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (dark.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (function.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)
我已经验证了 YAML,它很好
在 _config.yml
中,您使用的 baseurl 为 webpage
:
baseurl: "/webpage" # the subpath of your site, e.g. /blog
根据您的设置应该是 ''
:
baseurl: ""
然后加载资产的部分:
<link rel="stylesheet" href="{{ "/assets/fonts/font-awesome/css/font-awesome.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{site.baseurl}}/assets/stylesheets/{% if site.blog_theme == "light" %}light.css{% else %}dark.css{% endif %}">
将正确生成如下网址:
<link rel="stylesheet" href="/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/assets/stylesheets/dark.css">
Tn代替错误:
<link rel="stylesheet" href="/webpage/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/webpage/assets/stylesheets/dark.css">
我有一个 GitHub 托管 https://waltershub.github.io the repo is https://github.com/waltershub/waltershub.github.io
站点在本地正确构建所有资产 css 但在托管版本 none 上显示
控制台中的错误是:
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (font-awesome.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (dark.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (function.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)
我已经验证了 YAML,它很好
在 _config.yml
中,您使用的 baseurl 为 webpage
:
baseurl: "/webpage" # the subpath of your site, e.g. /blog
根据您的设置应该是 ''
:
baseurl: ""
然后加载资产的部分:
<link rel="stylesheet" href="{{ "/assets/fonts/font-awesome/css/font-awesome.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{site.baseurl}}/assets/stylesheets/{% if site.blog_theme == "light" %}light.css{% else %}dark.css{% endif %}">
将正确生成如下网址:
<link rel="stylesheet" href="/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/assets/stylesheets/dark.css">
Tn代替错误:
<link rel="stylesheet" href="/webpage/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/webpage/assets/stylesheets/dark.css">