hugo/docs/content/en/methods/page/PlainWords.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.1 KiB

title description categories keywords action
PlainWords Calls the Plain method, splits the result into a slice of words, and returns the slice.
related returnType signatures
methods/page/Content
methods/page/RawContent
methods/page/Plain
[]string
PAGE.PlainWords

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

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

{{% /note %}}

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