Jekyll reading time

Episode #25 - May 23, 2016 - 2 minutes

Subscribe to Jekyll Casts

Medium has a great feature on their blogging platform which shows an estimated reading time of a post.

Medium Michael Rose

So how would we accomplish this with Jekyll? Carlos Becker came up with a simple Liquid script which can calculate this for us.

First we need to calculate how many word are on the page using the number_of_words filter. Then we can divide the number of words by 180 (the average number of words per minute a human reads at) and we have an estimated read time.

We also need to handle the case where the estimated read time is less than 2 minutes (360 words). In this case we’ll show “1 min”.

{% assign words = content | number_of_words %}
{% if words < 360 %}
  1 min
{% else %}
  {{ words | divided_by:180 }} mins
{% endif %}

Finished read time

Subscribe to Jekyll Casts