Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -1,31 +1,20 @@
---
title: strings.CountWords
linkTitle: countwords
description: Counts the number of words in a string.
categories: [functions]
description: Returns the number of words in the given string.
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [countwords]
related:
- functions/go-template/len
- functions/strings/Count
- functions/strings/CountRunes
- functions/strings/RuneCount
returnType: int
signatures: [strings.CountWords INPUT]
relatedFunctions:
- len
- strings.Count
- strings.CountRunes
- strings.CountWords
- strings.RuneCount
aliases: [/functions/countwords]
---
The template function works similar to the [.WordCount page variable][pagevars].
```go-html-template
{{ "Hugo is a static site generator." | countwords }}
<!-- outputs a content length of 6 words. -->
{{ "Hugo is a static site generator." | countwords }} → 6
```
[pagevars]: /variables/page/