

hexo-generator-readtime
HEXO package that provides analytics on the read time to review the post. Supports 48 languages! Can add or override langProfile defaults.
Install
$ npm install hexo-generator-readtime
📝 When defaultTime
is set to "auto
," it will calculate the fuzzy time based on the least "count" time for fuzzyTime.time_unit
. Example: 578sec becomes "about 10 minutes".
If you define defaultTime
as "seconds", "minutes", etc., the time returned is more precise whereas "auto" will provide a very rough estimation.
How to use
After you have installed this plugin, it will run anytime you run hexo server
or hexo generate
.
readTime will read the lang
value in your front-matter to select the correct language profile. If this value is missing, it will attempt to read the _config.yml
setting. If both of these are missing, then it will default to en
(English).
It updates the front-matter of your posts to include the analytics data. The following parameters are added:
readTime | String that represents the estimated time to read the article. Printed in the detected language's native text. |
imgCount | Count of images found in the file. |
vidCount | Count of videos detected in the file. |
wordCount | Count of words in the file. This works very well for non-Asian languages. Some languages don't employ the space character as a word boundary. For Asian languages such as Chinese, Korean, Japanese, and Vietnamese, another method is required to create word tokens. |
wsCount | Count of white-space characters detected in the file. This is only useful for non-Asian languages. |
charCount | Letters detected for the given language in the file. |
cbCount | Count of code blocks in the file. |
👉🏻 Note: it only reads the posts from the /source/_posts/
folder. You can reference these values in your EJS template files from the object post
. For example: <%= post.readTime %>
. This plugin updates both in-memory post
object and the markdown file.
Parameter definitions
Below are the definitions for each parameter and expected values.
readtime:
defaultTime: auto
imgReadTime: 12
vidReadTime: 60
langProfile:
"{your lang}":
name: "My Lang"
nativeName: "myLanguage"
family: "Earth-Moon"
region: ["Earth", "Moon"]
unicodeRange: ["\u0021-\u007E"]
charPerMin: 999
wordsPerMin: 333
fuzzyTime:
pattern: %(time_unit)s %(count)d%(approx)s
approx: apx
time_unit:
second: sec
seconds: secs
minute: min
minutes: mins
hour: h
hours: h
day: d
days: d
month: m
months: m
year: y
years: y
Options
Note: this is completely optional as the plugin already has several languages predefined.
You can configure plugin overrides in your root _config.yml
. For example:
readtime:
defaultTime: seconds
imgReadTime: 12
langProfile:
ar:
name: "Arabic"
nativeName: "العربية"
family: "Afro-Asiatic"
region: ["Middle East", "North Africa"]
unicodeRange: ["\u0021-\u007E", "\u0600-\u06FF", "\u0750-\u077F", "\u0870-\u089F" "\u08A0-\u08FF", "\uFB50-\uFDFF", "\uFE70-\uFEFF"]
charPerMin: 612
wordsPerMin: 138
fuzzyTime:
pattern: %(time_unit)s %(count)d %(approx)s
approx: حوالي
time_unit:
second: ثانية
seconds: ثواني
minute: دقيقة
minutes: دقائق
hour: ساعة
hours: ساعات
day: يوم
days: أيام
month: شهر
months: شهور
year: سنة
years: سنوات
en:
name: "English"
unicodeRange: ["a-zA-Z0-9"]
charPerMin: 987
wordsPerMin: 228
fuzzyTime:
pattern: %(approx)s %(count)d %(time_unit)s
approx: "About"
time_unit:
second: "second"
seconds: "seconds"
minute: "minute"
minutes: "minutes"
hour: "hour"
hours: "hours"
day: "day"
days: "days"
month: "month"
months: "months"
year: "year"
years: "years"
jp:
charPerMin: 357
wordsPerMin: 193
zh:
charPerMin: 255
wordsPerMin: 158
Custom Language
You can add a custom language in your root _config.yml
file.
readtime:
langProfile:
"my-lang":
charPerMin: 1500
wordsPerMin: 300
fuzzyTime:
pattern: %(approx)s %(count)d%(time_unit)s
approx: "appx"
time_unit:
second: "sec"
minute: "min"
List of supported languages
Arabic | العربية | ar |
Bengali | বাংলা | bn |
German | Deutsch | de |
English | English | en |
Greek | Ελληνικά | el |
Spanish | Español | es |
Persian (Farsi) | فارسی | fa |
Finnish | suomi | fi |
French | Français | fr |
Gujarati | ગુજરાતી | gu |
Hebrew | עִבְרִית | he |
Hindi | हिन्दी | hi |
Armenian | հայերեն | hy |
Italian | Italiano | it |
Jin | 晋语 | jin |
Japanese | 日本語 | ja |
Javanese | Basa Jawa | jv |
Georgian | ქართული | ka |
Korean | 한국어 | ko |
Latin | Latīna | la |
Dutch | Nederlands | nl |
Punjabi | ਪੰਜਾਬੀ | pa |
Polish | polski | pl |
Pashto | پښتو | ps |
Portuguese | Português | pt |
Southern Min (Hokkien, Teochew) | 閩南語 (福建話, 潮州話) | nan |
Norwegian Norsk | Bokmål | nb |
Norwegian Nynorsk | nynorsk | nn |
Marathi | मराठी | mr |
Russian | Русский | ru |
Sinhala | සිංහල | si |
Slovenian | slovenščina | sl |
Swedish | Svenska | sv |
Tamil | தமிழ் | ta |
Telugu | తెలుగు | te |
Thai | ไทย | th |
Turkish | Türkçe | tr |
Vietnamese | Tiếng Việt | vi |
Urdu | اردو | ur |
Yue Chinese | 粤语 | yue |
Wu (including Shanghainese) | 吴语 (含上海话) | wuu |
Chinese (Mandarin) | 中文 (普通话) | zh-CN |
Chinese (Simplified) | 中文 (简体) | zh-Hans |
Chinese (Traditional) | 中文 (繁體) | zh-Hant |
Chinese (Hong Kong) | 中文 (香港) | zh-HK |
Chinese (Cantonese, Macau) | 中文 (廣東話, 澳門) | zh-MO |
Chinese (Singapore) | 中文 (普通话) | zh-SG |
Chinese (Taiwan) | 中文 (繁體中文) | zh-TW |
Chinese | 中文 (简体) | zh |
Don't see your language here?
Please submit an issue to request your language to be added. It helps if you can suggest the profile details too. Otherwise, I need to research it and that can take time.
You can also make feature requests and submit language corrections.
This package is sponsored by LoreZyra, you can find him at his Website, also Github

