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 }} → 27Counting runes in a string that contains HTML tags:
{{ "<p>Hugo is a <em>static</em> site generator.</p>" | strings.CountRunes }} → 27Counting runes in a string that contains Chinese characters:
{{ "Hugo 是一个静态网站生成器" | strings.CountRunes }} → 14Last updated:
October 28, 2026
:
content: Apply style guide to strings functions (d6de31ebd)
Improve this page