mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 04:14:24 +00:00
Renaming indexes to taxonomies in docs
This commit is contained in:
parent
a4a1e39a51
commit
b198cb26ba
6 changed files with 145 additions and 175 deletions
|
@ -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
|
important to provide both here. We require this, rather than using inflection in
|
||||||
effort to support as many languages as possible.*
|
effort to support as many languages as possible.*
|
||||||
|
|
||||||
{{% highlight yaml %}}
|
---
|
||||||
---
|
indexes:
|
||||||
indexes:
|
category: "categories"
|
||||||
category: "categories"
|
baseurl: "http://spf13.com/"
|
||||||
baseurl: "http://spf13.com/"
|
title: "Steve Francia is spf13.com"
|
||||||
title: "Steve Francia is spf13.com"
|
---
|
||||||
---
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## /layouts/indexes/category.html
|
## /layouts/indexes/category.html
|
||||||
|
|
||||||
For each index type a template needs to be provided to render the index page.
|
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`/.
|
In the case of categories, this will render the content for /categories/`CATEGORYNAME`/.
|
||||||
|
|
||||||
{{% highlight html %}}
|
{{ template "chrome/header.html" . }}
|
||||||
{{ template "chrome/header.html" . }}
|
{{ template "chrome/subheader.html" . }}
|
||||||
{{ template "chrome/subheader.html" . }}
|
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<div>
|
<div>
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
{{ range .Data.Pages }}
|
{{ range .Data.Pages }}
|
||||||
{{ .Render "summary"}}
|
{{ .Render "summary"}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{ template "chrome/footer.html" }}
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
|
{{ template "chrome/footer.html" }}
|
||||||
|
|
||||||
## Assigning indexes to content
|
## Assigning indexes to content
|
||||||
|
|
||||||
Make sure that the index is set in the front matter:
|
Make sure that the index is set in the front matter:
|
||||||
|
|
||||||
{{% highlight json %}}
|
{
|
||||||
{
|
"title": "Hugo: A fast and flexible static site generator",
|
||||||
"title": "Hugo: A fast and flexible static site generator",
|
"categories": [
|
||||||
"categories": [
|
"Development",
|
||||||
"Development",
|
"Go",
|
||||||
"Go",
|
"Blogging"
|
||||||
"Blogging"
|
],
|
||||||
],
|
"slug": "hugo"
|
||||||
"slug": "hugo"
|
}
|
||||||
}
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
|
@ -21,13 +21,11 @@ each content piece are located in the usual place
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
{{% highlight html %}}
|
<ul id="tags">
|
||||||
<ul id="tags">
|
{{ range .Params.tags }}
|
||||||
{{ range .Params.tags }}
|
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
|
||||||
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## Rendering a Site's Indexes
|
## Rendering a Site's Indexes
|
||||||
|
|
||||||
|
@ -40,13 +38,11 @@ The following example displays all tag keys:
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
{{% highlight html %}}
|
<ul id="all-tags">
|
||||||
<ul id="all-tags">
|
{{ range .Site.Indexes.tags }}
|
||||||
{{ range .Site.Indexes.tags }}
|
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li>
|
||||||
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## Creating a menu based on indexes
|
## Creating a menu based on indexes
|
||||||
|
|
||||||
|
@ -63,60 +59,54 @@ called menu.html, then include it using the
|
||||||
### Example complete menu.html file
|
### Example complete menu.html file
|
||||||
This example will list all indexes, each of their keys and all the content assigned to each key.
|
This example will list all indexes, each of their keys and all the content assigned to each key.
|
||||||
|
|
||||||
{{% highlight html %}}
|
<section id="menu">
|
||||||
<section id="menu">
|
<ul>
|
||||||
<ul>
|
{{ range $indexname, $index := .Site.Indexes }}
|
||||||
{{ range $indexname, $index := .Site.Indexes }}
|
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
|
||||||
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
|
<ul>
|
||||||
<ul>
|
{{ range $key, $value := $index }}
|
||||||
{{ range $key, $value := $index }}
|
<li> {{ $key }} </li>
|
||||||
<li> {{ $key }} </li>
|
<ul>
|
||||||
<ul>
|
{{ range $value.Pages }}
|
||||||
{{ range $value.Pages }}
|
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
||||||
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
</li>
|
||||||
</li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
</section>
|
||||||
</section>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
### menu.html using a single index
|
### menu.html using a single index
|
||||||
It is more likely that you would want to use a single index for navigation.
|
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.
|
In this example we are using the `groups` index for our menu.
|
||||||
|
|
||||||
{{% highlight html %}}
|
<section id="menu">
|
||||||
<section id="menu">
|
|
||||||
<ul>
|
|
||||||
{{ range $key, $index := .Site.Indexes.groups }}
|
|
||||||
<li> {{ $key }} </li>
|
|
||||||
<ul>
|
<ul>
|
||||||
{{ range $index.Pages }}
|
{{ range $key, $index := .Site.Indexes.groups }}
|
||||||
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
<li> {{ $key }} </li>
|
||||||
|
<ul>
|
||||||
|
{{ range $index.Pages }}
|
||||||
|
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
</section>
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
|
|
||||||
### menu.html using a single index ordered by Popularity
|
### menu.html using a single index ordered by Popularity
|
||||||
|
|
||||||
{{% highlight html %}}
|
<section id="menu">
|
||||||
<section id="menu">
|
|
||||||
<ul>
|
|
||||||
{{ range .Site.Indexes.groups.ByCount }}
|
|
||||||
<li> {{ .Name }} </li>
|
|
||||||
<ul>
|
<ul>
|
||||||
{{ range .Pages }}
|
{{ range .Site.Indexes.groups.ByCount }}
|
||||||
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
<li> {{ .Name }} </li>
|
||||||
|
<ul>
|
||||||
|
{{ range .Pages }}
|
||||||
|
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
</section>
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
{{% /highlight %}}
|
|
|
@ -26,44 +26,40 @@ number of content assigned to that key or alphabetically.
|
||||||
|
|
||||||
## Example indexes.html file (alphabetical)
|
## Example indexes.html file (alphabetical)
|
||||||
|
|
||||||
{{% highlight html %}}
|
{{ template "chrome/header.html" . }}
|
||||||
{{ template "chrome/header.html" . }}
|
{{ template "chrome/subheader.html" . }}
|
||||||
{{ template "chrome/subheader.html" . }}
|
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<div>
|
<div>
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{{ $data := .Data }}
|
{{ $data := .Data }}
|
||||||
{{ range $key, $value := .Data.Index.Alphabetical }}
|
{{ range $key, $value := .Data.Index.Alphabetical }}
|
||||||
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{{ template "chrome/footer.html" }}
|
{{ template "chrome/footer.html" }}
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## Example indexes.html file (ordered)
|
## Example indexes.html file (ordered)
|
||||||
|
|
||||||
{{% highlight html %}}
|
{{ template "chrome/header.html" . }}
|
||||||
{{ template "chrome/header.html" . }}
|
{{ template "chrome/subheader.html" . }}
|
||||||
{{ template "chrome/subheader.html" . }}
|
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<div>
|
<div>
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{{ $data := .Data }}
|
{{ $data := .Data }}
|
||||||
{{ range $key, $value := .Data.Index.ByCount }}
|
{{ range $key, $value := .Data.Index.ByCount }}
|
||||||
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{ template "chrome/footer.html" }}
|
{{ template "chrome/footer.html" }}
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## Variables available to list of indexes pages.
|
## Variables available to list of indexes pages.
|
||||||
|
|
|
@ -6,6 +6,7 @@ aliases: ["/indexes/ordering/"]
|
||||||
weight: 60
|
weight: 60
|
||||||
menu:
|
menu:
|
||||||
main:
|
main:
|
||||||
|
identifier: "Ordering Taxonomies"
|
||||||
parent: 'taxonomy'
|
parent: 'taxonomy'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -20,25 +21,21 @@ Indexes can be ordered by either alphabetical key or by the number of content pi
|
||||||
|
|
||||||
### Order Alphabetically Example:
|
### Order Alphabetically Example:
|
||||||
|
|
||||||
{{% highlight html %}}
|
<ul>
|
||||||
<ul>
|
{{ $data := .Data }}
|
||||||
{{ $data := .Data }}
|
{{ range $key, $value := .Data.Index.Alphabetical }}
|
||||||
{{ range $key, $value := .Data.Index.Alphabetical }}
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||||
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
### Order by Popularity Example:
|
### Order by Popularity Example:
|
||||||
|
|
||||||
{{% highlight html %}}
|
<ul>
|
||||||
<ul>
|
{{ $data := .Data }}
|
||||||
{{ $data := .Data }}
|
{{ range $key, $value := .Data.Index.ByCount }}
|
||||||
{{ range $key, $value := .Data.Index.ByCount }}
|
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||||
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
|
|
||||||
[See Also Index Lists](/indexes/lists/)
|
[See Also Index Lists](/indexes/lists/)
|
|
@ -38,15 +38,13 @@ pluralization.
|
||||||
|
|
||||||
### config.yaml
|
### config.yaml
|
||||||
|
|
||||||
{{% highlight yaml %}}
|
---
|
||||||
---
|
indexes:
|
||||||
indexes:
|
tag: "tags"
|
||||||
tag: "tags"
|
category: "categories"
|
||||||
category: "categories"
|
baseurl: "http://spf13.com/"
|
||||||
baseurl: "http://spf13.com/"
|
title: "Steve Francia is spf13.com"
|
||||||
title: "Steve Francia is spf13.com"
|
---
|
||||||
---
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
||||||
## Assigning index values to content
|
## Assigning index values to content
|
||||||
|
|
||||||
|
@ -61,20 +59,18 @@ and assign all keys you want this content to match against.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
{{% highlight json %}}
|
{
|
||||||
{
|
"title": "Hugo: A fast and flexible static site generator",
|
||||||
"title": "Hugo: A fast and flexible static site generator",
|
"tags": [
|
||||||
"tags": [
|
"Development",
|
||||||
"Development",
|
"Go",
|
||||||
"Go",
|
"fast",
|
||||||
"fast",
|
"Blogging"
|
||||||
"Blogging"
|
],
|
||||||
],
|
"categories" : [
|
||||||
"categories" : [
|
"Development"
|
||||||
"Development"
|
]
|
||||||
]
|
"slug": "hugo",
|
||||||
"slug": "hugo",
|
"project_url": "http://github.com/spf13/hugo"
|
||||||
"project_url": "http://github.com/spf13/hugo"
|
}
|
||||||
}
|
|
||||||
{{% /highlight %}}
|
|
||||||
|
|
|
@ -41,18 +41,16 @@ The following variables are available to the index template:
|
||||||
**.Data.`singular`** The index itself.<br>
|
**.Data.`singular`** The index itself.<br>
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
{{% highlight html %}}
|
{{ template "chrome/header.html" . }}
|
||||||
{{ template "chrome/header.html" . }}
|
{{ template "chrome/subheader.html" . }}
|
||||||
{{ template "chrome/subheader.html" . }}
|
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<div>
|
<div>
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
{{ range .Data.Pages }}
|
{{ range .Data.Pages }}
|
||||||
{{ .Render "summary"}}
|
{{ .Render "summary"}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{ template "chrome/footer.html" }}
|
{{ template "chrome/footer.html" }}
|
||||||
{{% /highlight %}}
|
|
Loading…
Reference in a new issue