Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Post previews for Github Pages (a la wordpress)
{% for post in site.posts limit:5 %}
<div class="box">
<div class="clearfix"></div>
<div class="right big">
{% assign breakIndex = -1 %}
{% for element in post.content %}
{% if element contains '<!--more-->' %}
{% assign breakIndex = forloop.index %}
{% endif %}
{% endfor %}
{% for element in post.content limit: breakIndex %}
{{ element }}
{% endfor %}
<p><a href="{{post.url}}">Read this entry...</a></p>
{% endfor %}
Copy link

artgon commented Nov 13, 2011

Since Github pages is using Liquid 2.2.0, there is no split tag. Therefore, I had to improvise this preview method. Since I imported all my posts from Wordpress, they are split using the "more" tag, as seen above.

Copy link

luin commented Dec 14, 2011


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