hugo/docs/content/indexes/lists.md

2.3 KiB

title date aliases linktitle groups groups_weight
Index Lists 2013-07-01
/doc/indexes/
/extras/indexes
Lists
indexes
40

An index list is a list of all the keys that are contained in the index. When a template is present, this will be rendered at /IndexPlural/

Hugo also supports creating pages that list your values for each index along with the number of content items associated with the index key. These are global pages, not attached to any specific content, but rather display the meta data in aggregate.

To have hugo create these list of indexes pages, simply create a template in /layouts/indexes/ called indexes.html

Hugo can order the meta data in two different ways. It can be ordered by the number of content assigned to that key or alphabetically.

Example indexes.html file (alphabetical)

{{% highlight html %}} {{ template "chrome/header.html" . }} {{ template "chrome/subheader.html" . }}

{{ .Title }}

    {{ $data := .Data }} {{ range $key, $value := .Data.Index.Alphabetical }}
  • {{ $value.Name }} {{ $value.Count }}
  • {{ end }}
{{ template "chrome/footer.html" }} {{% /highlight %}}

Example indexes.html file (ordered)

{{% highlight html %}} {{ template "chrome/header.html" . }} {{ template "chrome/subheader.html" . }}

{{ .Title }}

    {{ $data := .Data }} {{ range $key, $value := .Data.Index.ByCount }}
  • {{ $value.Name }} {{ $value.Count }}
  • {{ end }}

{{ template "chrome/footer.html" }} {{% /highlight %}}

Variables available to list of indexes pages.

.Title The title for the content.
.Date The date the content is published on.
.Permalink The Permanent link for this page.
.RSSLink Link to the indexes' rss link.
.Data.Singular The singular name of the index
.Data.Plural The plural name of the index
.Data.Index The Index itself
.Data.Index.Alphabetical The Index alphabetized
.Data.Index.ByCount The Index ordered by popularity