HUGO
Menu
GitHub 90272 stars Mastodon

strings.RuneCount

Returns the number of runes in the given string, including whitespace and HTML tags.
Syntax
strings.RuneCount STRING
Returns
int

Usage

The strings.RuneCount function returns the number of runes in the given string, including whitespace and HTML tags. In contrast, the strings.CountRunes function excludes whitespace and HTML tags.

Examples

{{ "Hugo is a static site generator." | strings.RuneCount }} → 32

Counting runes in a string that contains HTML tags:

{{ "<p>Hugo is a <em>static</em> site generator.</p>" | strings.RuneCount }} → 48

Counting runes in a string that contains Chinese characters:

{{ "Hugo 是一个静态网站生成器" | strings.RuneCount }} → 15