Last Updated: July 27, 2023
·
5.549K
· heyitsgarrett

Easily create blog post excerpts for Jekyll and Github Pages

Github Pages, combined with Jekyll, is an amazing quick and easy way to publish your site and blog. The framework is purposefully bare, prioritizing simplicity and straightforward rendering.

To generate automatic excerpts, place this inside your main blog post loop:

{% if post.content contains '<!--more-->' %}
    {{ post.content | split:'<!--more-->' | first }}
{% else %}
    <!-- Case for when no excerpt is defined -->
{% endif %}

And in the posts themselves, insert <!--more--> after the section you want exposed, similar to the approach Wordpress takes:

Excerpt content to appear on both the main blog loop and the individual post.

<!--more-->

The rest of the post, as seen only in the single blog post.