1

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>
marcanuy
  • 23,118
  • 9
  • 64
  • 113
zeleven
  • 436
  • 1
  • 6
  • 21

1 Answers1

3

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>
marcanuy
  • 23,118
  • 9
  • 64
  • 113