如何修复 GitHub Pages 存储库重定向到不正确的地址?

问题描述 投票:0回答:1

在启用了 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 讨论论坛上发布了此内容,但什么也没得到)

javascript html css github github-pages
1个回答
0
投票

/
表示网站的根目录,而不是存储库主页。 试试这个:

<a href="/repo"> Go to main page </a>
© www.soinside.com 2019 - 2024. All rights reserved.