HUGO
Menu
GitHub 90307 stars Mastodon

strings.CountRunes

Returns the number of runes in the given string, excluding whitespace and HTML tags.
Syntax
strings.CountRunes STRING
Returns
int
Alias
countrunes

Usage

The strings.CountRunes function returns the number of runes in the given string, excluding whitespace and HTML tags. In contrast, the strings.RuneCount function counts every rune in a string.

Examples

{{ "Hugo is a static site generator." | strings.CountRunes }} → 27

Counting runes in a string that contains HTML tags:

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

Counting runes in a string that contains Chinese characters:

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