网页无法在 GitHub 页面上正确呈现

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

how it rendering on github page我的网页(托管在 GitHub Pages 上)的内容和布局未按预期呈现。该网页似乎只有我的存储库名称。

what it looks like when it runs locally有人可以告诉我可能的原因是什么吗 链接到我的 github 存储库 https://github.com/subhadarshini1954/Blog-project

node.js git express github ejs
1个回答
0
投票

您当前到样式表的链接使用绝对路径,这意味着它以斜杠(/)开头。当您在本地运行网站时,这可以正常工作,但在 GitHub Pages 上不起作用,因为您的网站不是托管在域的根目录下,而是托管在以存储库命名的子目录中。例如,相对于您的存储库网站 url 将类似于 https://subhadarshini1954.github.io/Blog-project/,您的样式表 URL 将是 https://subhadarshini1954.github.io/styles/ layout.css,不存在。因此,在调用样式表的地方,删除斜杠,使其看起来如下所示:

<link rel="stylesheet" href="styles/layout.css">
- 只需删除前面的斜杠。

© www.soinside.com 2019 - 2024. All rights reserved.