Hugo: .WordCount, .FuzzyWordCount, .ReadingTime is not set on posts with <!--more-->

Created on 27 Apr 2018  路  2Comments  路  Source: gohugoio/hugo

I recently updated from version .31 to .40.1 (using the pre-compiled deb file in the release), and now some of my older posts have 0 minute read times.

You can see it here: http://tech.townsourced.com/

And here is the line where I'm very simply calling the {{.ReadingTime}} variable in my template:

https://github.com/timshannon/tech.townsourced.com/blob/241eb6763d1708418f2274c8b03c8d3d09c4a5a7/layouts/post/single.html#L16

Not sure why it's working on my newer posts and not my older ones.

Let me know if there is any additional info I can provide.

Bug

Most helpful comment

OK, I have reproduced this:

  • When you use <!--more--> then
  • .WordCount, .FuzzyWordCount, .ReadingTime is always 0.

Note that all the other related fields (PlainWords, Plain, Content) are set correctly in both scenarios. So this is the word stats.

All 2 comments

This is a bug introduced in the latest release. We only calculate this information if it is used, and we reworked this logic in 0.40 ... and sadly had a hole in the test coverage in this case. I'm sorry about that. The fix is easy, but I will make sure to add proper tests before I issue a patch release.

The only current workaround is to remove the "summary marker".

OK, I have reproduced this:

  • When you use <!--more--> then
  • .WordCount, .FuzzyWordCount, .ReadingTime is always 0.

Note that all the other related fields (PlainWords, Plain, Content) are set correctly in both scenarios. So this is the word stats.

Was this page helpful?
0 / 5 - 0 ratings