How to display post summary on index page using Jekyll?

html, jekyll, markdown

Solution

Use YAML front matter and define a separate title per post, like this:

---
title: Efficient smuflet based kwoxel trees
---

Post content goes here.

Then you can use or not use `post.title` as you please.

Or, if you want to write a separate summary (not just the first n characters) for each post, just add a field for that summary in the front matter as well.

Problem

I am using Jekyll to create a blog by following this excellent tutorial. I would like to add a post summary on the index page. I tried using: post.content | truncatewords:50 | strip_html it works but it displays the entire post until the 50 word count is reached. This includes the heading too. I would like to just summarize the actual content of the post. How can I structure my posts to do this?

Original source