【问题标题】:GitHub Jekyll cannot find postsGitHub Jekyll 找不到帖子
【发布时间】:2013-06-25 22:21:03
【问题描述】:

我有一个 Markdown 页面 index2.md 如下:

---
layout: plain
title: Index2
---

test Index2


<ul class="posts">
    {% for post in site.posts %}
      <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
</ul>

但是这不能显示我的博文

<body>
    <div class="wrapper">
      <header>
        <h1>Nodeclipse.github.io</h1>
        <p>Resource for Nodeclipse developers</p>


        <p class="view"><a href="https://github.com/Nodeclipse">View My GitHub Profile</a></p>

      </header>
      <section>
            <div>            
            <p>test Index2</p>

<p>  <ul class="posts"></p>

<p>  </ul></p>

            </div>
      </section>
      <footer>
        <p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
      </footer>
    </div>
    <script src="javascripts/scale.fix.js"></script>

  </body>

即博客列表为空。

【问题讨论】:

  • 您的问题似乎是您的 ul 块被解释为文本。你在index2.md 中使用标签吗?如果是这样,请尝试将制表符转换为空格。
  • 是的。但是仍然缺少帖子

标签: ruby github markdown jekyll


【解决方案1】:

Markdown 将您的缩进 HTML 解释为内容,并帮助您将其包装在 &lt;p&gt; 标记中。

Markdown 将通过 raw 传递 HTML,这是您想要的,但前提是开始和结束标记根本不缩进。因此,取消缩进打开和关闭 &lt;ul&gt;&lt;/ul&gt; 标记,Markdown 将使整个 HTML 块不受干扰。所以它应该是这样的:

test Index2

<ul class="posts">
    {% for post in site.posts %}
        <li>
            <span>{{ post.date | date_to_string }}</span>
            &raquo;
            <a href="{{ post.url }}">{{ post.title }}</a>
        </li>
    {% endfor %}
</ul>

【讨论】:

  • 看看nodeclipse.github.io/index2的来源我已经更正了缩进。
  • 我查看了您的存储库,您的 _posts 目录似乎有一个前导空格,这意味着 Jekyll 没有找到它。运行mv \ _posts _posts 修复它,最后享受 Jekyll :)
  • 是的,这正是问题所在。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多