2

I blog with Jekyll. In my source/index.html (I reconfigured the paths in _config.yml) I have written:

{{ site.posts }} 

But when I compile it it gives no results. I am sure that I have posts, they are compiled and work as supposed.

I don't know where to start troubleshooting, have anyone else had such problem?

4

3 回答 3

1

site.post 返回液化 Jekyll::Post 对象的数组。您可以通过简单地编写来检查帖子的数量:

{{ site.posts.size }} 

你可以遍历他们写作:

<ul>
{% for post in site.posts %}
  <li class="post">
    <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
  </li>
{% endfor %}
</ul>
于 2012-10-21T21:52:00.247 回答
0

在 Jekyll 中,帖子需要位于_posts要包含在{{ site.posts }}变量中的文件夹中。

您很有可能只是省略了文件夹名称中的下划线。

于 2013-09-18T02:00:45.857 回答
0

验证发布时间,它发生在过去,未来的帖子不会添加到site.posts.

于 2016-02-15T18:30:35.147 回答