在启用了 GitHub 页面的存储库中,网站可以重定向到
user.github.io
而不是 user.github.io/repo
。
我在存储库中有此代码:
<!-- anotherPage.html -->
<a href="/"> Go to main page </a>
本来应该去
user.github.io/repo
,但是却去user.github.io
还有一个问题是css和字体/图像文件无法匹配。目录结构是这样的:
root
|_ css
| |_ code.css
|
|_ assets
|_ image.png
|_ font.woff
并且在
code.css
中我无法执行background: url("/assets/image.png");
或@font { src: url("/assets/font.woff"); }
,因为它将签入user.github.io
而不是user.github.io/repo
我该如何解决这个问题?
我可以写下所有的
<a href=""
和 <link href=""
语句,在开头添加 https://user.github.io/repo/
但这不是一个很好的解决方案,因为当我在本地网络服务器上测试时,网站会崩溃。
(我在 GitHub 讨论论坛上发布了此内容,但什么也没得到)
/
表示网站的根目录,而不是存储库主页。
试试这个:
<a href="/repo"> Go to main page </a>