Jekyll for循环可以按预期工作

时间:2017-08-18 08:02:36

标签: jekyll liquid yaml-front-matter

我创建了一个新页面,有一个for循环来显示帖子列表,但它无法正常工作 enter image description here

这是我的代码:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
      {{ post.excerpt }}
    </li>
  {% endfor %}
</ul>
</body>
</html>

1 个答案:

答案 0 :(得分:3)

添加前面的内容,以便Jekyll知道它必须处理它。

只需在文件开头添加两行破折号:

---
---
<!DOCTYPE html> 
<html> 
<head> <title></title> </head> 
<body> 
<ul> 
{% for post in site.posts %} 
<li> <a href="{{ post.url }}">{{ post.title }}</a> {{ post.excerpt }} </li>
 {% endfor %} 
</ul> 
</body>
 </html>
相关问题