Make Hugo Count Korean Words Correctly in Page Summaries (hasCJKLanguage, isCJKLanguage)
On Hugo post list pages, the beginning of an article is displayed as a summary limited to a specific number of words, usually 70 words. However, this word count is calculated based on languages such as English by default, so Korean and other CJK text is not counted correctly, and summaries may be displayed too long.
Configure in the Settings File
To count Korean characters correctly and display short summaries, set hasCJKLanguage to true in the settings file as follows.
For config.toml
hasCJKLanguage = true
For config.yaml
hasCJKLanguage: true
With this, Hugo’s internal .Summary and .WordCount work correctly for Korean, and shorter summary text is displayed.
Configure Per Page
If you want to configure it for each page, set isCJKLanguage to true in the front matter as follows.
---
title: Post title
date: "2023-05-14"
isCJKLanguage: true
---
Post body
Use hasCJKLanguage in the settings file and isCJKLanguage in the front matter of Markdown files.