zeleven
zeleven

Reputation: 456

Jekyll for loop can't work as expected

I created a new page, there was a for loop to display the list of posts, but it can't work as expcted enter image description here

and here is my code:

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

Upvotes: 1

Views: 86

Answers (1)

marcanuy
marcanuy

Reputation: 23982

Add front matter so Jekyll knows it has to process it.

Simply add two lines of the dashes at the beginning of the file:

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

Upvotes: 3

Related Questions