Medium has a nice little feature that shows an estimated reading time on posts.

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.

The algorithm

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