Jekyll for 循环无法按预期工作

Jekyll for loop can't work as expected

我创建了一个新页面,有一个用于显示帖子列表的 for 循环,但它无法按预期工作

这是我的代码:

<!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>

添加前端内容以便 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>