Renaming indexes to taxonomies in docs

This commit is contained in:
spf13 2014-05-15 09:57:36 -04:00
parent a4a1e39a51
commit b198cb26ba
6 changed files with 145 additions and 175 deletions

View file

@ -15,50 +15,43 @@ First step is to define the index in your config file.
important to provide both here. We require this, rather than using inflection in
effort to support as many languages as possible.*
{{% highlight yaml %}}
---
indexes:
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
{{% /highlight %}}
---
indexes:
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
## /layouts/indexes/category.html
For each index type a template needs to be provided to render the index page.
In the case of categories, this will render the content for /categories/`CATEGORYNAME`/.
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }}
{{% /highlight %}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }}
## Assigning indexes to content
Make sure that the index is set in the front matter:
{{% highlight json %}}
{
"title": "Hugo: A fast and flexible static site generator",
"categories": [
"Development",
"Go",
"Blogging"
],
"slug": "hugo"
}
{{% /highlight %}}
{
"title": "Hugo: A fast and flexible static site generator",
"categories": [
"Development",
"Go",
"Blogging"
],
"slug": "hugo"
}

View file

@ -21,13 +21,11 @@ each content piece are located in the usual place
### Example
{{% highlight html %}}
<ul id="tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
{{% /highlight %}}
<ul id="tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
## Rendering a Site's Indexes
@ -40,13 +38,11 @@ The following example displays all tag keys:
### Example
{{% highlight html %}}
<ul id="all-tags">
{{ range .Site.Indexes.tags }}
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li>
{{ end }}
</ul>
{{% /highlight %}}
<ul id="all-tags">
{{ range .Site.Indexes.tags }}
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li>
{{ end }}
</ul>
## Creating a menu based on indexes
@ -63,60 +59,54 @@ called menu.html, then include it using the
### Example complete menu.html file
This example will list all indexes, each of their keys and all the content assigned to each key.
{{% highlight html %}}
<section id="menu">
<ul>
{{ range $indexname, $index := .Site.Indexes }}
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
<ul>
{{ range $key, $value := $index }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
{{% /highlight %}}
<section id="menu">
<ul>
{{ range $indexname, $index := .Site.Indexes }}
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
<ul>
{{ range $key, $value := $index }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
### menu.html using a single index
It is more likely that you would want to use a single index for navigation.
In this example we are using the `groups` index for our menu.
{{% highlight html %}}
<section id="menu">
<ul>
{{ range $key, $index := .Site.Indexes.groups }}
<li> {{ $key }} </li>
<section id="menu">
<ul>
{{ range $index.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ range $key, $index := .Site.Indexes.groups }}
<li> {{ $key }} </li>
<ul>
{{ range $index.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
{{ end }}
</ul>
</section>
{{% /highlight %}}
</section>
### menu.html using a single index ordered by Popularity
{{% highlight html %}}
<section id="menu">
<ul>
{{ range .Site.Indexes.groups.ByCount }}
<li> {{ .Name }} </li>
<section id="menu">
<ul>
{{ range .Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ range .Site.Indexes.groups.ByCount }}
<li> {{ .Name }} </li>
<ul>
{{ range .Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
{{ end }}
</ul>
</section>
{{% /highlight %}}
</section>

View file

@ -26,44 +26,40 @@ number of content assigned to that key or alphabetically.
## Example indexes.html file (alphabetical)
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.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 %}}
<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" }}
## Example indexes.html file (ordered)
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.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>
<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 %}}
{{ template "chrome/footer.html" }}
## Variables available to list of indexes pages.

View file

@ -6,6 +6,7 @@ aliases: ["/indexes/ordering/"]
weight: 60
menu:
main:
identifier: "Ordering Taxonomies"
parent: 'taxonomy'
---
@ -20,25 +21,21 @@ Indexes can be ordered by either alphabetical key or by the number of content pi
### Order Alphabetically Example:
{{% highlight html %}}
<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>
{{% /highlight %}}
<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>
### Order by Popularity Example:
{{% highlight html %}}
<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>
{{% /highlight %}}
<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>
[See Also Index Lists](/indexes/lists/)

View file

@ -38,15 +38,13 @@ pluralization.
### config.yaml
{{% highlight yaml %}}
---
indexes:
tag: "tags"
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
{{% /highlight %}}
---
indexes:
tag: "tags"
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
## Assigning index values to content
@ -61,20 +59,18 @@ and assign all keys you want this content to match against.
### Example
{{% highlight json %}}
{
"title": "Hugo: A fast and flexible static site generator",
"tags": [
"Development",
"Go",
"fast",
"Blogging"
],
"categories" : [
"Development"
]
"slug": "hugo",
"project_url": "http://github.com/spf13/hugo"
}
{{% /highlight %}}
{
"title": "Hugo: A fast and flexible static site generator",
"tags": [
"Development",
"Go",
"fast",
"Blogging"
],
"categories" : [
"Development"
]
"slug": "hugo",
"project_url": "http://github.com/spf13/hugo"
}

View file

@ -41,18 +41,16 @@ The following variables are available to the index template:
**.Data.`singular`** The index itself.<br>
## Example
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }}
{{% /highlight %}}
{{ template "chrome/footer.html" }}