jekyll GitHub 页面页面未加载 Assets

标签 jekyll assets github-pages jekyll-theme

我有一个 GitHub 托管 https://waltershub.github.io repo 是 https://github.com/waltershub/waltershub.github.io
该站点使用所有 Assets 和 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)
我已经验证了 YAML,它很好

最佳答案

_config.yml您正在使用 webpage 的 baseurl :

baseurl: "/webpage" # the subpath of your site, e.g. /blog
根据您的设置何时应该是'' :
baseurl: ""
然后是加载 Assets 的部分:
<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">
而不是错误:
<link rel="stylesheet" href="/webpage/assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/webpage/assets/stylesheets/dark.css">

关于jekyll GitHub 页面页面未加载 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46478421/

相关文章:

javascript - node_modules 文件夹上的 Github Pages 404

Jekyll & Liquid : Output category list with post count?

javascript - 如何使用 Jeykll 防止 Vue 组件的属性名称小写或小写转换

android - 更新Assets文件夹的解决方法

javascript - 部署到 Github Pages 后不显示 Angular 图像

jekyll - Jekyll 中 localhost 和 github 页面的 Baseurl 行为不同

ruby - 错误 : IPv6 address must be 16 bytes

html - 如何去除 float 标签?

java - assetManager.loadModel 导致 AssetNotFound 异常

fonts - 在yii2中的哪里放字体?