Skip to content

Instantly share code, notes, and snippets.

@claws
Created March 3, 2012 13:10
Show Gist options
  • Save claws/1965992 to your computer and use it in GitHub Desktop.
Save claws/1965992 to your computer and use it in GitHub Desktop.
Generate excerpt content in Jekyll for use on Gihub pages. This extracts the post content within the '<!-- excerpt start -->' and '<!-- excerpt end -->' comment tags.
layout title
post
Jekyll Excerpts

This text becomes the excerpt text displayed on the main page

This test is not displayed.

---
layout: default
title: "Main Page"
---
<h2>Recent Posts</h2>
<div class="posts">
{% for post in site.posts limit:5 %}
<div class="post">
<div class="title"><a href="{{ post.url }}">{{post.title }}</a></div>
<div class="date">Posted on {{ post.date | date: "%B %d %Y" }}</div>
<div class="excerpt">{{ post.content | split:'<!-- excerpt end -->' | first | split:'<!-- excerpt start -->' | last }}</div>
<p><a href="{{post.url}}">Read more »</a></p>
</div>
<hr />
{% endfor %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment