Skip to content

Instantly share code, notes, and snippets.

@roachhd
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roachhd/77d641047bb839882846 to your computer and use it in GitHub Desktop.
Save roachhd/77d641047bb839882846 to your computer and use it in GitHub Desktop.
Jekyll - Quick post word count anx readinv time

Jekyll Word count and reading time

If less than 10 words on the page it wont show the word count.

{% capture words %}
  {{ page.content | number_of_words | minus: 10 }}
{% endcapture %}
{% unless words contains "-" %}
  {{ words | plus: 10 | append: " words" }}
{% endunless %}

{% capture words %}
  {{ page.content | number_of_words | minus: 10 }}
{% endcapture %}
{% unless words contains "-" %}
  {{ words | plus: 10 | divided_by: 180 | append: " minute read" }}
{% endunless %}

TODO: Get it to stop counting front matter.


@roachhd
Copy link
Author

roachhd commented Dec 12, 2014

Figured out its not counting the front matter, just the liquid.

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