shithub: hugo

Download patch

ref: 6f9db4a784a58c150863ada2cfd79090a0227d47
parent: 53b7d5b8a1a42cf19b76a7a901461bd1c2478368
author: Tatsushi Demachi <[email protected]>
date: Wed Aug 27 18:50:06 EDT 2014

Add document about page grouping functions

--- a/docs/content/templates/list.md
+++ b/docs/content/templates/list.md
@@ -215,3 +215,39 @@
     <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
     </li>
     {{ end }}
+
+## Grouping Content
+
+Hugo provides some grouping functions for list pages. You can use them to
+group pages by Section, Date etc.
+
+Here are a variety of different ways you can group the content items in
+your list templates:
+
+### Grouping by Page field
+
+    {{ range .Data.Pages.GroupBy "Section" "asc" }}
+    <h3>{{ .Key }}</h3>
+    <ul>
+        {{ range .Data }}
+        <li>
+        <a href="{{ .Permalink }}">{{ .Title }}</a>
+        <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
+        </li>
+        {{ end }}
+    </ul>
+    {{ end }}
+
+### Grouping by Page date
+
+    {{ range .Data.Pages.GroupByDate "2006-01" "desc" }}
+    <h3>{{ .Key }}</h3>
+    <ul>
+        {{ range .Data }}
+        <li>
+        <a href="{{ .Permalink }}">{{ .Title }}</a>
+        <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
+        </li>
+        {{ end }}
+    </ul>
+    {{ end }}