2013-10-31 09:51:13 -04:00
|
|
|
---
|
|
|
|
title: "Index Lists"
|
|
|
|
date: "2013-07-01"
|
|
|
|
aliases: ["/doc/indexes/", "/extras/indexes"]
|
|
|
|
linktitle: "Lists"
|
|
|
|
groups: ["indexes"]
|
|
|
|
groups_weight: 40
|
|
|
|
---
|
|
|
|
|
|
|
|
An index list is a list of all the keys that are contained in the index. When a
|
2014-01-10 21:19:19 -05:00
|
|
|
template is present, this will be rendered at `/IndexPlural/`
|
2013-10-31 09:51:13 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
2014-01-10 21:19:19 -05:00
|
|
|
### Example indexes.html file (alphabetical)
|
|
|
|
|
|
|
|
{{% highlight html %}}
|
|
|
|
{{ template "chrome/header.html" . }}
|
|
|
|
{{ template "chrome/subheader.html" . }}
|
|
|
|
|
|
|
|
<section id="main">
|
|
|
|
<div>
|
|
|
|
<h1 id="title">{{ .Title }}</h1>
|
|
|
|
<ul>
|
|
|
|
{{ $data := .Data }}
|
|
|
|
{{ range $key, $value := .Data.Index.Alphabetical }}
|
|
|
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{{ template "chrome/footer.html" }}
|
|
|
|
{{% /highlight %}}
|
|
|
|
|
|
|
|
### Example indexes.html file (ordered)
|
|
|
|
|
|
|
|
{{% highlight html %}}
|
|
|
|
{{ template "chrome/header.html" . }}
|
|
|
|
{{ template "chrome/subheader.html" . }}
|
|
|
|
|
|
|
|
<section id="main">
|
|
|
|
<div>
|
|
|
|
<h1 id="title">{{ .Title }}</h1>
|
|
|
|
<ul>
|
|
|
|
{{ $data := .Data }}
|
|
|
|
{{ range $key, $value := .Data.Index.ByCount }}
|
|
|
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
{{ template "chrome/footer.html" }}
|
|
|
|
{{% /highlight %}}
|
2013-10-31 09:51:13 -04:00
|
|
|
|
|
|
|
### Variables available to list of indexes pages.
|
|
|
|
|
|
|
|
**.Title** The title for the content. <br>
|
|
|
|
**.Date** The date the content is published on.<br>
|
|
|
|
**.Permalink** The Permanent link for this page.<br>
|
|
|
|
**.RSSLink** Link to the indexes' rss link. <br>
|
|
|
|
**.Data.Singular** The singular name of the index <br>
|
|
|
|
**.Data.Plural** The plural name of the index<br>
|
|
|
|
**.Data.Index** The Index itself<br>
|
|
|
|
**.Data.Index.Alphabetical** The Index alphabetized<br>
|
|
|
|
**.Data.Index.ByCount** The Index ordered by popularity<br>
|