html - Github 页面未在子文件夹上加载 css

标签 html css github jekyll github-pages

知道为什么 github pages 停止在子文件夹中加载 css 和图像,它在网站的根目录下运行良好。

当我检查页面的源代码时,我看到了这个

"href="css/bootstrap-3.3.6/css/bootstrap.min.css">" 

代替

"href="/css/bootstrap-3.3.6/css/bootstrap.min.css">".

在我的配置文件中有一行

baseurl : /

--> crowd42.github.io

谢谢

最佳答案

它应该像 baseurl : "/" 那样工作,如果在加载 Assets 时使用该变量:

<link rel="stylesheet" href="{{site.baseurl}}css/main.css">

因为您似乎没有使用基本 url,您可以尝试在开头强制使用斜杠的根路径:

<link rel="stylesheet" href="/css/main.css">

或者包括绝对路径:

<link rel="stylesheet" href="{{'css/main.css'|absolute_url}}">

使用 baseurl: ""

关于html - Github 页面未在子文件夹上加载 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46790717/

相关文章:

windows - 更改 Git 用户名

jquery - 在表单中按回车键时,Bootstrap Dropdown 总是会聚焦

html - SVG 坐标偏移

javascript - 是否可以使用 ng 风格的动画? ( Angular )

javascript - 根据子内容调整父容器的大小

linux - 两个 git 命令 gitbranch -d <branch_name> 和 gitbranch -D <branch_name> 有什么区别?

python - 如何从eclipse中的代码导入odoo模块

javascript - 使用 CKeditor 工具获取电子邮件上的 HTML 标签后

javascript - 如何段落绘制到 Canvas 上的文本

javascript - 如何禁用 "Save"直到字段通过验证。没有 <form> 标签