mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-18 01:01:43 -04:00
685 B
685 B
title | description | categories | keywords | params | aliases | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
collections.Shuffle | Returns a random permutation of a given array or slice. |
|
|
{{ 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>