botbotbot 's blog

Read more feature on jekyll

Github Pages Tips:
Github Pages always complie jekyll with --safe option that will
disable plugins but some plugin can work with Github Pages.
List of Jekyll Plguins that working on Github > Pages

Easy ways: using excerpt option of > jekyll
Customized excerpt separator in > Jekyll

Just using truncate they not checking html tag that make your site look terrible and Github Pages not support custom ruby script that place in _plugins. The better way is using split with custom tags.

Replace `` in index.html in jekyll directory with

    
    {% if post.content contains "<!-- more -->" %}
      {{ post.content | split:"<!-- more -->" | first % }}
      <div style="text-align:right;">
        <a href="{{ post.url }}" style="color:#000;"> Read More </a>
      </div>
    {% else %}
      {{ post.content }}
    {% endif %}
    

In your contents add <!-- more -->

---
layout: post
title: Read more feature on jekyll
tags: [jekyll]
---
Hello, world

<!-- more -->

You can't see this message via index.html

References:

  1. Truncating blog posts in Jekyll
  2. Jekyll - Read More without plugin
  3. A Jekyll plugin that truncates HTML while preserving markup structure.