Group.md - hugo - [fork] hugo port for 9front
(HTM) git clone https://git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
Group.md (943B)
---
1 ---
2 title: collections.Group
3 description: Groups the given page collection by the given key.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [group]
9 returnType: any
10 signatures: [collections.Group KEY PAGES]
11 aliases: [/functions/group]
12 ---
13
14 ```go-html-template
15 {{ $new := .Site.RegularPages | first 10 | group "New" }}
16 {{ $old := .Site.RegularPages | last 10 | group "Old" }}
17 {{ $groups := slice $new $old }}
18 {{ range $groups }}
19 <h3>{{ .Key }}{{/* Prints "New", "Old" */}}</h3>
20 <ul>
21 {{ range .Pages }}
22 <li>
23 <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
24 <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
25 </li>
26 {{ end }}
27 </ul>
28 {{ end }}
29 ```
30
31 The page group you get from `group` is of the same type you get from the built-in [group methods](/quick-reference/page-collections/#group) in Hugo. The example above can be [paginated](/templates/pagination/).