jekyll GitHub 页面页面未加载资产

Wal*_*hub 4 assets jekyll github-pages jekyll-theme

我有一个 GitHub 托管 https://waltershub.github.io回购是https://github.com/waltershub/waltershub.github.io

该站点使用所有资产和 css 在本地正确构建,但在托管版本上没有显示

控制台中的错误是:

[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)
Run Code Online (Sandbox Code Playgroud)

我已经验证了 YAML,它很好

mar*_*nuy 5

_config.yml您使用的 baseurl 中webpage

baseurl: "/webpage" # the subpath of your site, e.g. /blog
Run Code Online (Sandbox Code Playgroud)

根据您的设置何时应该是''

baseurl: ""
Run Code Online (Sandbox Code Playgroud)

然后是加载资产的部分:

<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 %}">
Run Code Online (Sandbox Code Playgroud)

将正确生成如下网址:

<link rel="stylesheet" href="/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/assets/stylesheets/dark.css">
Run Code Online (Sandbox Code Playgroud)

而不是错误:

<link rel="stylesheet" href="/webpage/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/webpage/assets/stylesheets/dark.css">
Run Code Online (Sandbox Code Playgroud)