I am using the following HTML code to find the estimated reading time for my blog posts:
<abbr title="Estimated reading time">ERT {{ page.title }}</abbr>
{% assign words_total = page.content | replace: '<script type="math/tex">', '' | replace: '<script type="math/tex; mode=display">', '' | replace: '</script>', '' | strip_html | number_of_words %}
{% assign words_without_code = page.content | replace: '<pre class="highlight">', '<!--' | replace: '</pre>', '-->' | replace: '<script type="math/tex">', '' | replace: '<script type="math/tex; mode=display">', '' | replace: '</script>', '' | strip_html | number_of_words %}
{% assign words_without_math = page.content | strip_html | number_of_words %}
{% assign words_without_either = page.content | replace: '<pre class="highlight">', '<!--' | replace: '</pre>', '-->' | strip_html | number_of_words %}
{% assign words_code = words_total | minus: words_without_code | divided_by: 2.0 %}
{% assign words_math = words_total | minus: words_without_math | times: 2.0 %}
{% assign words = words_without_either | plus: words_code | plus: words_math | round %}
{% assign ert = words | divided_by:250 | at_least: 1 %}
{{ ert }} minute{% if ert != 1 %}s{% endif %}
I want to show the reading time on my home page next to my date. However, the script shows me different reading times in the home page, and in the actual blog post. I reckon it’s not reading the article content but just the home page. Any ideas how to go about this? I’m kinda new at this whole thing.