【问题标题】:Jekyll Deployment on Github Pages doesn't format correctly and links brokenGithub 页面上的 Jekyll 部署格式不正确并且链接断开
【发布时间】:2013-11-04 04:42:54
【问题描述】:

我最近正在学习如何使用 Jekyll 和 Github,我很难让我的网站在网上正确显示,但是当我运行时它确实在本地正确显示:

jekyll serve --baseurl ''

我正在处理的 Github 存储库是 http://yungkickz.github.io/kingwizard

Github Tree

任何帮助或提示都会非常有帮助。

编辑:基本上整个网站都缺少正确的 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>

【问题讨论】:

    标签: ruby jekyll liquid github-pages


    【解决方案1】:

    从your site的源码来看,我注意到了一些问题:

    1. 您对 HTML、CSS 和 JavaScript 文件的许多引用都以 // 开头。尽管您的配置文件中进行了设置,但出于某种原因,似乎 site.baseurl 在 GitHub 上设置为 /。但是,您经常在路径中的site.baseurl 之后添加斜杠,这会导致出现第二个斜杠。

    2. 因为site.baseurl 是/,浏览器会期望在http://yungkickz.github.io/SOME_PATH 找到您的文件。但是,您的站点实际上已部署到 http://yungkickz.github.io/kingwizard,因此您的链接应该指向 http://yungkickz.github.io/kingwizard/SOME_PATH。

    3. 由于 404 错误,您的 CSS 样式未加载,这就是您的网站看起来格式不正确的原因。

    之前:

    <link href="{{ site.baseurl }}/css/bootstrap.css" rel="stylesheet">
    

    之后:

    <link href="/kingwizard/css/bootstrap.css" rel="stylesheet">
    

    【讨论】:

    • 谢谢,在我的header.html 中它基本上看起来像您的“之前”,但我应该在代码中的每个点单独更改路径吗?我认为site.baseurl 会动态地为我完成那部分,所以我不必这样做。我很抱歉,但我对此很陌生,但非常感谢您的帮助!
    • 没关系,我发现site.baseurl 的问题,所以你还是应该使用它。当我在本地运行jekyll serve --baseurl '' 时,我注意到输出的第一行是Configuration file: none。事实证明,jekyll(本地和 GitHub 上)没有加载您的配置文件,因为它被命名为 config.yml,而不是 _config.yml(它应该是什么)。
    • 很棒的发现!谢谢! (菜鸟错误)这肯定修复了 CSS 问题和许多其他错误!您是如何注意到 Configuration file: none 的,因为我在终端的 jekyll 中运行时没有看到。
    • 我不确定,我运行了与你相同的 jekyll 命令,我看到了。也许我们正在使用不同版本的 jekyll。顺便说一句,我注意到您提交了_site 目录。您可能希望将其删除并将其添加到 .gitignore。
    • .gitignore 我假设会忽略该目录,但我为什么要这样呢?我会搜索网络,但我想我会问你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多