我最近在学习如何使用 Jekyll 和 Github,我很难让我的网站在线正确显示,但当我运行时它在本地正确显示:
jekyll serve --baseurl ''
我正在处理的 Github 存储库是 http://yungkickz.github.io/kingwizard
任何帮助或提示都会非常有帮助。
编辑:基本上整个网站都缺少正确的 CSS,并且链接指向错误的位置;特别是第一个 Home 和 About 链接,因为任何其他链接都是为了测试而制作的。
我的config.yml:
name: kingwizard
description: wizardly blog
paginate: 5
url: "http://yungkickz.github.io"
baseurl: /kingwizard
markdown: rdiscount
我还在此处添加了 html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{{ site.description }}">
<meta name="author" content="">
<title>{{ site.name }}</title>
<!-- Bootstrap core CSS -->
<link href="{{ site.baseurl }}/css/bootstrap.css" rel="stylesheet">
<!-- Custom Arreis Style -->
<link href="{{ site.baseurl }}/css/custom-style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="{{ site.baseurl}}js/html5shiv.js"></script>
<script src="{{ site.baseurl}}js/respond.min.js"></script>
<![endif]-->
</head>
最佳答案
从your site的源码来看,我注意到了一些问题:
许多对 HTML、CSS 和 JavaScript 文件的引用都以
//
开头。似乎site.baseurl
出于某种原因在 GitHub 上设置为/
,尽管您的配置文件中进行了设置。但是,您经常在路径中的site.baseurl
之后添加附加斜杠,这会导致出现第二个斜杠。因为
site.baseurl
是/
,浏览器会期望在http://yungkickz.github.io/SOME_PATH
。但是,您的站点实际上已部署到http://yungkickz.github.io/kingwizard
,因此您的链接应指向http://yungkickz.github.io/kingwizard/SOME_PATH
代替。由于 404 错误,您的 CSS 样式未加载,这就是您的网站看起来格式不正确的原因。
之前:
<link href="{{ site.baseurl }}/css/bootstrap.css" rel="stylesheet">
之后:
<link href="/kingwizard/css/bootstrap.css" rel="stylesheet">
关于ruby - Github Pages 上的 Jekyll Deployment 格式不正确且链接已损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19761764/