mirror of
https://github.com/gohugoio/hugo.git
synced 2026-09-02 19:52:38 +00:00
27 lines
715 B
Markdown
27 lines
715 B
Markdown
---
|
|
title: countwords
|
|
linktitle: countwords
|
|
description: Counts the number of words in a string that has been passed to it.
|
|
godocref:
|
|
date: 2017-02-01
|
|
publishdate: 2017-02-01
|
|
lastmod: 2017-02-01
|
|
categories: [functions]
|
|
tags: [counting, word count]
|
|
signature:
|
|
workson: []
|
|
hugoversion:
|
|
relatedfuncs: [countrunes]
|
|
deprecated: false
|
|
aliases: [/functions/countrunes/,/functions/countwords/]
|
|
---
|
|
|
|
`countwords` tries to convert the passed content to a string and counts each word in it. The template function works similar to the [.WordCount page variable][pagevars].
|
|
|
|
```html
|
|
{{ "Hugo is a static site generator." | countwords }}
|
|
<!-- outputs a content length of 6 words. -->
|
|
```
|
|
|
|
|
|
[pagevars]: /variables/page-variables/ |