2025-07-07 13:17:48 +02:00

685 B

title description categories keywords params aliases
collections.Shuffle Returns a random permutation of a given array or slice.
functions_and_methods
aliases returnType signatures
shuffle
any
collections.Shuffle COLLECTION
/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>