Skip to content

Instantly share code, notes, and snippets.

@Phlow
Last active March 13, 2021 17:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Phlow/04f635e4d1fc928b1157 to your computer and use it in GitHub Desktop.
Save Phlow/04f635e4d1fc928b1157 to your computer and use it in GitHub Desktop.
This include splits the content of {{ content }} into two parts if Jekyll finds an excerpt separator. This allows extra styling of the first part to enlarge the the fontsize of the teaser for example.
{% comment %}
#
# Explanation:
#
# This include splits the content of {{ content }} into
# two parts if Jekyll finds an excerpt separator. This allows
# extra styling of the first part to enlarge the the fontsize
# of the teaser for example.
#
# The excerpt separator can be defined directly in your
# _config.yml or via front matter. If no separator is defined
# Jekyll will fall back to the default separator <!--more-->.
# If no separator is set, Jekyll just spits out the content
# without splitting.
#
{% endcomment %}
{% capture page_content %}{{ content }}{% endcapture %}
{% if site.excerpt_separator %}{% assign separator = site.excerpt_separator %}{% else %}{% assign separator = '<!--more-->' %}{% endif %}
{% if page_content contains separator %}
{% assign entry = page_content | split: separator %}
{{ entry | first | remove: '<p>' | prepend: '<p class="lead">' }}
{{ entry | last }}
{% else %}
{{ page_content }}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment