HUGO
Menu
GitHub 90466 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.

The strings.Fields function splits the string around each instance of one or more consecutive whitespace characters, as defined by unicode.IsSpace. 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

To render the content in a named scope, call Markup.Render.PlainWords on a Page object.