mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
30a20122b7
# Conflicts: # docs/data/docs.yaml
857 B
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. |
|
|
|
{{ 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.