我的 jekyll 博客在 Github 页面上托管时无法正确呈现

My jekyll blog won't render properly when hosted on Github pages

我在 Windows 10 机器上,几天前我下载了一个 Jekyll 主题用作我的个人投资组合网站,然后创建了一个名为 gh-pages 的分支并将其推送到该分支渲染不正确,这里是 URL:https://nezmustafa123.github.io/blog/

有人知道是什么原因造成的吗?

您的网站 URL 配置有问题,而不是从 https://nezmustafa123.github.io/blog/assets/css/main.css it is looking for http://localhost:4000/assets/css/main.css.

加载 CSS

在配置文件中 _config.yml 将以下密钥添加到您的网站域:

url: http://localhost:4000

并添加基础url:baseurl: "blog".

然后调整你的头包括使用site.url_includes/head.html中使用base_url前缀或者生成包含url和absolute_url的绝对路径:

 <link rel="stylesheet" type="text/css" href="{{ "/assets/css/main.css" | relative_url }}">

Relative URL

Prepend the baseurl value to the input. Useful if your site is hosted at a subpath rather than the root of the domain.

Absolute URL

Prepend the url and baseurl value to the input.