Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jekyll excerpt plugin
# This goes in _plugins/excerpt.rb
module Jekyll
class Post
alias_method :original_to_liquid, :to_liquid
def to_liquid
'excerpt' => content.match('<!--more-->') ? content.split('<!--more-->').first : nil
module Filters
def mark_excerpt(content)
content.gsub('<!--more-->', '<p><span id="more"></span></p>')
<!-- This snippet checks for an excerpt variable that I assign to true on my index pages, but not on the post pages, then checks to see if the post has an excerpt to see if it should render the excerpt of the post or the whole thing -->
<div class="entry">
{% if excerpt and post.excerpt %}
{{ post.excerpt }}
<p> <a href="{{ post.url }}/#more" class="more-link"><span class="readmore">Read the rest of this entry »</span></a></p>
{% else %}
{{ post.content | mark_excerpt }}
{% endif %}
Copy link

legatoo commented Dec 23, 2014

jekyll 2.5.1 | Error: wrong number of arguments (1 for 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment