Files
hugo/docs/content/en/functions/collections/Shuffle.md
T
Bjørn Erik Pedersen 30a20122b7 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
# Conflicts:
#	docs/data/docs.yaml
2026-02-14 12:14:33 +01:00

857 B

title, description, categories, keywords, params, aliases
title description categories keywords params aliases
collections.Shuffle Returns a slice by randomizing the element order of the given slice.
random
functions_and_methods
aliases returnType signatures
shuffle
[]any
collections.Shuffle SLICE
/functions/shuffle
{{ collections.Shuffle (slice "a" "b" "c") }} → [b a c] 

The result will vary from one build to the next.

To render an unordered list of 5 random pages from a page collection:

<ul>
  {{ $p := site.RegularPages }}
  {{ range $p | collections.Shuffle | first 5 }}
    <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
  {{ end }}
</ul>

{{< new-in 0.149.0 />}}

Using the collections.D function for the same task is significantly faster.