How to display first N posts in Jekyll

Viewed 613

I'm using Jekyll 2 for my blog. I'm also using jekyll-paginate to display the first 5 posts in the home page.

Now I would like to stop using jekyll-paginate, since it's polluting the sitemap with pages I don't want.

This is how my home page looks like, after removing the pagination:

---
layout: default
---

<div class="blog-index">
  {% assign index = true %}
  {% for post in site.posts %}
  {% assign content = post.content %}
    <article>
      {% include article.html %}
    </article>
  {% endfor %}
</div>

This displays all the posts, but I only want the first 5. In Ruby you can do .take(5) or .first(5), so I tried that, but it doesn't work.

How do I display only the 5 most recent posts?

1 Answers
Related