hugo/docs/content/en/functions/go-template/len.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

908 B

title description categories keywords action aliases
len Returns the length of a string, slice, map, or collection.
aliases related returnType signatures
functions/strings/Count
functions/strings/CountRunes
functions/strings/CountWords
functions/strings/RuneCount
int
len VALUE
/functions/len

With a string:

{{ "ab" | len }} → 2
{{ "" | len }} → 0

With a slice:

{{ slice "a" "b" | len }} → 2
{{ slice | len }} → 0

With a map:

{{ dict "a" 1 "b" 2  | len }} → 2
{{ dict | len }} → 0

With a collection:

{{ site.RegularPages | len }} → 42

You may also determine the number of pages in a collection with:

{{ site.RegularPages.Len }} → 42

{{% include "functions/go-template/_common/text-template.md" %}}