【问题标题】:New Jekyll Pages Not Linking To Style Sheet新的 Jekyll 页面未链接到样式表
【发布时间】:2016-04-30 15:00:48
【问题描述】:

我创建了一个新的 Jekyll 页面,在顶部包含相应的 YAML Front Matter 信息。我的问题是页面在没有任何样式的情况下呈现。经过检查,我看到 head 标签是空的,所以 CSS 没有链接。我确定我错过了一些非常明显的东西,但我很难过。我看到样式表链接到索引页面,而不是我的新页面,我不知道我缺少什么来包含链接到我的样式表的头部数据。这是我在新页面中的内容。

---
layout: default
title: New Site
---

<div>
  <div>

      <h2>
        <a href="test.html">Our Sweet Test Page</a>
      </h2>

      <section>
        <article class="dope-page">
          <h1>Test Headline</h1>
        </article>
      </section>

    </div>
</div>

【问题讨论】:

  • 你把新页面放在哪里?
  • 它在我的根目录中,与 index.html 并排。对吗?

标签: html css jekyll


【解决方案1】:

这正是您的模板未加载时发生的情况。您的 _layouts 目录中是否有带有样式表链接的 default.html 文件?

【讨论】:

  • 是的,这也是我的想法。 default.html 文件存在于 _layout 目录中,并带有指向样式表的链接——适用于索引页面,但不适用于我的新测试页面。
  • 扩展名是.md吗?
  • 掌心 命中注定,这是一个简单的错字。不过感谢您的努力,您的思路是正确的。
  • 谢谢!编码愉快!
【解决方案2】:

在我看来,Jekyll 使用layout 参数在index.html 旁边渲染页面,并在_layouts 文件夹中找到布局。在您的情况下,您使用layout: default,因此您应该检查_layouts/default.html 文件。

jekyll new your_awesome_site 生成的default.html 文件应如下所示:

<!DOCTYPE html>
<html>

  {% include head.html %}

  <body>

    {% include header.html %}

    <div class="page-content">
      <div class="wrapper">
        {{ content }}
      </div>
    </div>

    {% include footer.html %}

  </body>

</html>

css 文件位于_includes/head.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-19
    相关资源
    最近更新 更多