| 1 |
--- |
| 2 |
title: ReadingTime |
| 3 |
description: Returns the estimated reading time, in minutes, for the given page. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: int |
| 9 |
signatures: [PAGE.ReadingTime] |
| 10 |
--- |
| 11 |
|
| 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. |
| 13 |
|
| 14 |
> [!NOTE] |
| 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. |
| 16 |
|
| 17 |
```go-html-template |
| 18 |
{{ printf "Estimated reading time: %d minutes" .ReadingTime }} |
| 19 |
``` |
| 20 |
|
| 21 |
Reading speed varies by language. Create language-specific estimated reading times on your multilingual project using site parameters. |
| 22 |
|
| 23 |
{{< code-toggle file=hugo >}} |
| 24 |
[languages] |
| 25 |
[languages.de] |
| 26 |
contentDir = 'content/de' |
| 27 |
label = 'Deutsch' |
| 28 |
locale = 'de-DE' |
| 29 |
weight = 2 |
| 30 |
[languages.de.params] |
| 31 |
reading_speed = 179 |
| 32 |
[languages.en] |
| 33 |
contentDir = 'content/en' |
| 34 |
label = 'English' |
| 35 |
locale = 'en-US' |
| 36 |
weight = 1 |
| 37 |
[languages.en.params] |
| 38 |
reading_speed = 228 |
| 39 |
{{< /code-toggle >}} |
| 40 |
|
| 41 |
Then in your template: |
| 42 |
|
| 43 |
```go-html-template |
| 44 |
{{ $readingTime := div (float .WordCount) .Site.Params.reading_speed }} |
| 45 |
{{ $readingTime = math.Ceil $readingTime }} |
| 46 |
``` |
| 47 |
|
| 48 |
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. |
| 49 |
|
| 50 |
[`hasCJKLanguage`]: /configuration/all/#hascjklanguage |
| 51 |
[`isCJKLanguage`]: /content-management/front-matter/#iscjklanguage |