aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/en/functions/strings/CountWords.md
blob: e6915e6cd47fc280415e4b62212ad5229f064d99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
title: strings.CountWords
linkTitle: countwords
description: Counts the number of words in a string.
categories: [functions]
keywords: []
menu:
  docs:
    parent: functions
function:
  aliases: [countwords]
  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.  -->
```


[pagevars]: /variables/page/