[Hexo] Use hexo-word-counter plugin to count symbols and time to read for articles in Hexo

hexo-word-counter

Hexo is a fast, simple & powerful blog framework. It use plugins to provide features powerful APIs for limitless extensibility. Various plugins are available to support most template engines (EJS, Pug, Nunjucks, and many others). Easily integrate with existing NPM packages (Babel, PostCSS, Less/Sass, etc).

hexo-word-counter plugin will count symbols and time to read for Hexo articles.

Installation

Use npm to install hexo-word-counter package.

1
2
3
$ npm install hexo-word-counter --save

$ hexo clean

Configuration

You can set options of hexo-word-counter in the Hexo’s _config.yml (which locates in the root dir of your blog):

1
2
3
4
5
6
7
8
9
10
# _config.yml
symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
exclude_codeblock: false
awl: 4
wpm: 275
suffix: "mins."

If symbols_count_time option is not specified, the default parameters will be used.

Parameters

  • awl – Average Word Length (chars count in word). Default: 4. You can check this here.

    • CN ≈ 2

    • EN ≈ 5

    • RU ≈ 6

  • wpm – Words Per Minute. Default: 275. You can check this here.

    • Slow ≈ 200

    • Normal ≈ 275

    • Fast ≈ 350

  • suffix – If time to read less then 60 minutes, added suffix as string parameter.

    If not defined, mins. will be used as default.

  • exclude_codeblock – Allow to exclude all content inside code blocks for more accurate words counting.

    If not defined, false will be used as default.


Note for Chinese users: because in Chinese language average word length about ~1.5 and if you at most cases write posts in Chinese (without mixed English), recommended to set awl to 2 and wpm to 300.
But if you usualy mix your posts with English, awl to 4 and wpm to 275 will be nice.


NexT theme

This plugin integrated in «NexT» and after plugin enabled in main Hexo config, you may adjust options in NexT config:

1
2
3
4
5
6
7
# _config.next.yml

# Post wordcount display settings
# Dependencies: https://github.com/next-theme/hexo-word-counter
symbols_count_time:
separated_meta: true
item_text_total: false

Finally, you can visit your site in the browser, and check whether the site works correctly after Hexo restarted or regenerated.

References

[1] GitHub - next-theme/hexo-word-counter: ⏰ Symbols count and time to read of articles for Hexo. - https://github.com/next-theme/hexo-word-counter

[2] Hexo - https://hexo.io/