HUGO
Menu
GitHub 89803 stars Mastodon

PlainWords

Returns a slice of words created by calling the Plain method and splitting the result.
Syntax
PAGE.PlainWords
Returns
[]string

The PlainWords method on a Page object calls the Plain method, then uses Go’s strings.Fields function to split the result into words.

Fields splits the string s around each instance of one or more consecutive whitespace characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only whitespace.

As a result, elements within the slice may contain leading or trailing punctuation.

{{ .PlainWords }}

To determine the approximate number of unique words on a page:

{{ .PlainWords | uniq }} → 42