Skip to content

Commit 713f17b

Browse files
authored
content: Clarify affect of hasCJKLanguage and isCJKLanguage
1 parent c7cb6f7 commit 713f17b

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎content/en/configuration/all.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ aliases: [/getting-started/configuration/]
127127
: See [configure front matter][].
128128

129129
`hasCJKLanguage`
130-
: (`bool`) Whether to automatically detect [CJK](g) languages in content. Affects the values returned by the [`WordCount`][] and [`FuzzyWordCount`][] methods. Default is `false`.
130+
: (`bool`) Whether to automatically detect [CJK](g) languages in content. Affects the values returned by the [`FuzzyWordCount`][], [`ReadingTime`][], [`Summary`][], and [`WordCount`][] methods. To override this behavior on a given page, set the [`isCJKLanguage`][] field in its front matter. Default is `false`.
131131

132132
`HTTPCache`
133133
: See [configure HTTP cache][].
@@ -360,10 +360,12 @@ Some configuration settings, such as menus and custom parameters, can be defined
360360
[`GitInfo`]: /methods/page/gitinfo/
361361
[`Lastmod`]: /methods/page/lastmod/
362362
[`MainSections`]: /methods/site/mainsections/
363+
[`ReadingTime`]: /methods/page/readingtime/
363364
[`Summary`]: /methods/page/summary/
364365
[`WordCount`]: /methods/page/wordcount/
365366
[`disabled`]: /configuration/languages/#disabled
366367
[`erroridf`]: /functions/fmt/erroridf/
368+
[`isCJKLanguage`]: /content-management/front-matter/#iscjklanguage
367369
[`os.UserCacheDir`]: https://pkg.go.dev/os#UserCacheDir
368370
[`segments`]: /configuration/segments/
369371
[`strings.Title`]: /functions/strings/title/

‎content/en/content-management/front-matter.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The most common front matter fields are `date`, `draft`, `title`, and `weight`,
6363
: (`bool`) Applicable to [leaf bundles][], whether to set the `render` and `list` [build options][] to `never`, creating a headless bundle of [page resources][].
6464

6565
`isCJKLanguage`
66-
: (`bool`) Whether the content language is in the [CJK](g) family. This value determines how Hugo calculates word count, and affects the values returned by the [`WordCount`][], [`FuzzyWordCount`][], [`ReadingTime`][], and [`Summary`][] methods on a `Page` object.
66+
: (`bool`) Whether the content is in a [CJK](g) language. This value determines how Hugo calculates word count, and affects the values returned by the [`FuzzyWordCount`][], [`ReadingTime`][], [`Summary`][], and [`WordCount`][] methods on a `Page` object. When set, this value takes precedence over the automatic detection enabled by the [`hasCJKLanguage`][] setting in your project configuration.
6767

6868
`keywords`
6969
: (`[]string`) An array of keywords, typically rendered within a `meta` element within the `head` element of the published HTML file, or used as a [taxonomy](g) to classify content. Access these values from a template using the [`Keywords`][] method on a `Page` object.
@@ -307,10 +307,10 @@ To override the default time zone, set the [`timeZone`][] in your project config
307307
[`Description`]: /methods/page/description/
308308
[`Draft`]: /methods/page/draft/
309309
[`ExpiryDate`]: /methods/page/expirydate/
310-
[`FuzzyWordCount`]: /methods/page/wordcount/
310+
[`FuzzyWordCount`]: /methods/page/fuzzywordcount/
311311
[`GetTerms`]: /methods/page/getterms/
312312
[`Keywords`]: /methods/page/keywords/
313-
[`Lastmod`]: /methods/page/date/
313+
[`Lastmod`]: /methods/page/lastmod/
314314
[`Layout`]: /methods/page/layout/
315315
[`LinkTitle`]: /methods/page/linktitle/
316316
[`Param`]: /methods/page/param/
@@ -325,6 +325,7 @@ To override the default time zone, set the [`timeZone`][] in your project config
325325
[`Type`]: /methods/page/type/
326326
[`Weight`]: /methods/page/weight/
327327
[`WordCount`]: /methods/page/wordcount/
328+
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage
328329
[`timeZone`]: /configuration/all/#timezone
329330
[aliases]: /content-management/urls/#aliases
330331
[build options]: /content-management/build-options/

‎content/en/methods/page/FuzzyWordCount.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ params:
1616
To get the exact word count, use the [`WordCount`][] method.
1717

1818
> [!NOTE]
19-
> For content in CJK languages (Chinese, Japanese, Korean), set [`hasCJKLanguage`][] to `true` in your site configuration. This setting affects FuzzyWordCount in the same way as WordCount.
19+
> For content in [CJK](g) languages, set [`hasCJKLanguage`][] to `true` in your project configuration. When enabled, Hugo applies CJK word counting rules to pages containing CJK characters. To override this behavior on a given page, set the [`isCJKLanguage`][] field in its front matter.
2020
21-
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage
2221
[`WordCount`]: /methods/page/wordcount/
22+
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage
23+
[`isCJKLanguage`]: /content-management/front-matter/#iscjklanguage

‎content/en/methods/page/ReadingTime.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ params:
99
signatures: [PAGE.ReadingTime]
1010
---
1111

12-
The estimated reading time is calculated by dividing the number of words in the content by the reading speed.
13-
14-
By default, Hugo assumes a reading speed of 212 words per minute. For CJK languages, it assumes 500 words per minute.
12+
Hugo calculates the estimated reading time by dividing the number of words in the content by a reading speed of 212 words per minute.
1513

1614
> [!NOTE]
17-
> To use the CJK reading speed, set [`hasCJKLanguage`][] to `true` in your site configuration. Hugo automatically applies the CJK rate when this setting is enabled and the page contains CJK characters.
15+
> For content in [CJK](g) languages, set [`hasCJKLanguage`][] to `true` in your project configuration. When enabled, Hugo applies CJK word counting rules and a reading speed of 500 words per minute to pages containing CJK characters. To override this behavior on a given page, set the [`isCJKLanguage`][] field in its front matter.
1816
1917
```go-html-template
2018
{{ printf "Estimated reading time: %d minutes" .ReadingTime }}
@@ -50,3 +48,4 @@ Then in your template:
5048
We cast the `.WordCount` to a float to obtain a float when we divide by the reading speed. Then round up to the nearest integer.
5149

5250
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage
51+
[`isCJKLanguage`]: /content-management/front-matter/#iscjklanguage

‎content/en/methods/page/WordCount.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ params:
1313
{{ .WordCount }} → 103
1414
```
1515

16-
To round up to nearest multiple of 100, use the [`FuzzyWordCount`][] method.
16+
To round up to the nearest multiple of 100, use the [`FuzzyWordCount`][] method.
1717

1818
> [!NOTE]
19-
> For content in CJK languages (Chinese, Japanese, Korean), set [`hasCJKLanguage`][] to `true` in your site configuration. When enabled, Hugo applies CJK word counting rules to pages containing CJK characters.
19+
> For content in [CJK](g) languages, set [`hasCJKLanguage`][] to `true` in your project configuration. When enabled, Hugo applies CJK word counting rules to pages containing CJK characters. To override this behavior on a given page, set the [`isCJKLanguage`][] field in its front matter.
2020
2121
[`FuzzyWordCount`]: /methods/page/fuzzywordcount/
2222
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage
23+
[`isCJKLanguage`]: /content-management/front-matter/#iscjklanguage

0 commit comments

Comments
 (0)