Replace .Data.Pages with .Pages

This commit is contained in:
Kaushal Modi 2018-07-16 16:15:54 -04:00 committed by Bjørn Erik Pedersen
parent 85d3712d05
commit 50df8bfb83
24 changed files with 102 additions and 102 deletions

View File

@ -170,7 +170,7 @@ Last but not least, we have to create the second list that contains all publicat
The layout for this page can be defined in the template `layouts/taxonomy/author.html`.
{{< code file="layouts/taxonomy/author.html" download="author.html" >}}
{{ range .Data.Pages }}
{{ range .Pages }}
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<span>written by {{ .Author.DisplayName }}</span>
{{ .Summary }}

View File

@ -178,7 +178,7 @@ This shortcode will convert the source code provided into syntax-highlighted HTM
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
@ -194,7 +194,7 @@ The `highlight` shortcode example above would produce the following HTML when th
<span style="color: #f92672">&lt;section</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;main&quot;</span><span style="color: #f92672">&gt;</span>
<span style="color: #f92672">&lt;div&gt;</span>
<span style="color: #f92672">&lt;h1</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;title&quot;</span><span style="color: #f92672">&gt;</span>{{ .Title }}<span style="color: #f92672">&lt;/h1&gt;</span>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render &quot;summary&quot;}}
{{ end }}
<span style="color: #f92672">&lt;/div&gt;</span>

View File

@ -1,7 +1,7 @@
---
title: Content Summaries
linktitle: Summaries
description: Hugo generates summaries of your content.
description: Hugo generates summaries of your content.
date: 2017-01-10
publishdate: 2017-01-10
lastmod: 2017-01-10
@ -57,7 +57,7 @@ Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> exactly
You can show content summaries with the following code. You could use the following snippet, for example, in a [section template][].
{{< code file="page-list-with-summaries.html" >}}
{{ range first 10 .Data.Pages }}
{{ range first 10 .Pages }}
<article>
<!-- this <div> includes the title summary -->
<div>
@ -78,4 +78,4 @@ Note how the `.Truncated` boolean valuable may be used to hide the "Read More...
[org]: /content-management/formats/
[pagevariables]: /variables/page/
[section template]: /templates/section-templates/
[section template]: /templates/section-templates/

View File

@ -134,7 +134,7 @@ Highlighting is carried out via the [built-in shortcode](/content-management/sho
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
@ -157,7 +157,7 @@ It is also possible to add syntax highlighting with GitHub flavored code fences.
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>

View File

@ -39,7 +39,7 @@ You can use `after` in combination with the [`first` function][] and Hugo's [pow
{{ define "main" }}
<section class="row featured-article">
<h2>Featured Article</h2>
{{ range first 1 .Data.Pages.ByPublishDate.Reverse }}
{{ range first 1 .Pages.ByPublishDate.Reverse }}
<header>
<h3><a href="{{.Permalink}}">{{.Title}}</a></h3>
</header>
@ -48,7 +48,7 @@ You can use `after` in combination with the [`first` function][] and Hugo's [pow
</section>
<div class="row recent-articles">
<h2>Recent Articles</h2>
{{ range first 3 (after 1 .Data.Pages.ByPublishDate.Reverse) }}
{{ range first 3 (after 1 .Pages.ByPublishDate.Reverse) }}
<section class="recent-article">
<header>
<h3><a href="{{.Permalink}}">{{.Title}}</a></h3>

View File

@ -21,8 +21,7 @@ aliases: []
```
{{ range first 10 .Data.Pages }}
{{ range first 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
```

View File

@ -23,8 +23,7 @@ aliases: []
```
{{ range last 10 .Data.Pages }}
{{ range last 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
```

View File

@ -26,7 +26,7 @@ This function is only available when applied to a single piece of content within
This example could render a piece of content using the content view located at `/layouts/_default/summary.html`:
```
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
```

View File

@ -23,7 +23,7 @@ needsexample: true
`where` filters an array to only the elements containing a matching value for a given field.
```go-html-template
{{ range where .Data.Pages "Section" "post" }}
{{ range where .Pages "Section" "post" }}
{{ .Content }}
{{ end }}
```
@ -45,7 +45,7 @@ series: golang
It can also be used with the logical operators `!=`, `>=`, `in`, etc. Without an operator, `where` compares a given field with a matching value equivalent to `=`.
```go-html-template
{{ range where .Data.Pages "Section" "!=" "post" }}
{{ range where .Pages "Section" "!=" "post" }}
{{ .Content }}
{{ end }}
```
@ -104,7 +104,7 @@ You can also put the returned value of the `where` clauses into a variable:
The following grabs the first five content files in `post` using the [default ordering](/templates/lists/) for lists (i.e., `weight => date`):
{{< code file="where-with-first.html" >}}
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ range first 5 (where .Pages "Section" "post") }}
{{ .Content }}
{{ end }}
{{< /code >}}
@ -114,7 +114,7 @@ The following grabs the first five content files in `post` using the [default or
You can also nest `where` clauses to drill down on lists of content by more than one parameter. The following first grabs all pages in the "blog" section and then ranges through the result of the first `where` clause and finds all pages that are *not* featured:
```go-html-template
{{ range where (where .Data.Pages "Section" "blog" ) ".Params.featured" "!=" "true" }}
{{ range where (where .Pages "Section" "blog" ) ".Params.featured" "!=" "true" }}
```
## Unset Fields
@ -129,7 +129,7 @@ Only the following operators are available for `nil`
* `!=`, `<>`, `ne`: True if the given field is set.
```go-html-template
{{ range where .Data.Pages ".Params.specialpost" "!=" nil }}
{{ range where .Pages ".Params.specialpost" "!=" nil }}
{{ .Content }}
{{ end }}
```

View File

@ -21,7 +21,7 @@ When using Hugo with [GitHub Pages](http://pages.github.com/), you can provide y
404 pages will have all the regular [page variables][pagevars] available to use in the templates.
In addition to the standard page variables, the 404 page has access to all site content accessible from `.Data.Pages`.
In addition to the standard page variables, the 404 page has access to all site content accessible from `.Pages`.
```
▾ layouts/

View File

@ -90,7 +90,7 @@ From the above base template, you can define a [default list template][hugolists
{{< code file="layouts/_default/list.html" download="list.html" >}}
{{ define "main" }}
<h1>Posts</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
<article>
<h2>{{ .Title }}</h2>
{{ .Content }}

View File

@ -36,9 +36,9 @@ The homepage, similar to other [list pages in Hugo][lists], accepts content and
See the homepage template below or [Content Organization][contentorg] for more information on the role of `_index.md` in adding content and front matter to list pages.
## `.Data.Pages` on the Homepage
## `.Pages` on the Homepage
In addition to the standard [page variables][pagevars], the homepage template has access to *all* site content via `.Data.Pages`.
In addition to the standard [page variables][pagevars], the homepage template has access to *all* site content via `.Pages`.
## Example Homepage Template
@ -58,8 +58,8 @@ The following is an example of a homepage template that uses [partial][partials]
{{.Content}}
</div>
<div>
<!-- Note that .Data.Pages is the equivalent of .Site.Pages on the homepage template. -->
{{ range first 10 .Data.Pages }}
<!-- Note that .Pages is the same as .Site.Pages on the homepage template. -->
{{ range first 10 .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>

View File

@ -504,7 +504,7 @@ Go allows you to do more than what's shown here. Using Hugo's [`where` function]
{{< code file="layouts/partials/upcoming-events.html" download="upcoming-events.html" >}}
<h4>Upcoming Events</h4>
<ul class="upcoming-events">
{{ range where .Data.Pages.ByDate "Section" "events" }}
{{ range where .Pages.ByDate "Section" "events" }}
{{ if ge .Date.Unix .Now.Unix }}
<li>
<!-- add span for event type -->

View File

@ -101,7 +101,7 @@ You can now access this `_index.md`'s' content in your list template:
</article>
<ul>
<!-- Ranges through content/post/*.md -->
{{ range .Data.Pages }}
{{ range .Pages }}
<li>
<a href="{{.Permalink}}">{{.Date.Format "2006-01-02"}} | {{.Title}}</a>
</li>
@ -172,7 +172,7 @@ This list template has been modified slightly from a template originally used in
<h1>{{ .Title }}</h1>
<ul>
<!-- Renders the li.html content view for each content/post/*.md -->
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "li"}}
{{ end }}
</ul>
@ -189,7 +189,7 @@ This list template has been modified slightly from a template originally used in
<div>
<h1>{{ .Title }}</h1>
<!-- ranges through each of the content files associated with a particular taxonomy term and renders the summary.html content view -->
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
@ -205,7 +205,7 @@ Hugo lists render the content based on metadata you provide in [front matter][].
{{< code file="layouts/partials/default-order.html" >}}
<ul>
{{ range .Data.Pages }}
{{ range .Pages }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -220,7 +220,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-weight.html" >}}
<ul>
{{ range .Data.Pages.ByWeight }}
{{ range .Pages.ByWeight }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -234,7 +234,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-date.html" >}}
<ul>
<!-- orders content according to the "date" field in front matter -->
{{ range .Data.Pages.ByDate }}
{{ range .Pages.ByDate }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -248,7 +248,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-publish-date.html" >}}
<ul>
<!-- orders content according to the "publishdate" field in front matter -->
{{ range .Data.Pages.ByPublishDate }}
{{ range .Pages.ByPublishDate }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -261,7 +261,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-expiry-date.html" >}}
<ul>
{{ range .Data.Pages.ByExpiryDate }}
{{ range .Pages.ByExpiryDate }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -275,7 +275,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-last-mod.html" >}}
<ul>
<!-- orders content according to the "lastmod" field in front matter -->
{{ range .Data.Pages.ByLastmod }}
{{ range .Pages.ByLastmod }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -289,7 +289,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-length.html" >}}
<ul>
<!-- orders content according to content length in ascending order (i.e., the shortest content will be listed first) -->
{{ range .Data.Pages.ByLength }}
{{ range .Pages.ByLength }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -303,7 +303,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-title.html" >}}
<ul>
<!-- ranges through content in ascending order according to the "title" field set in front matter -->
{{ range .Data.Pages.ByTitle }}
{{ range .Pages.ByTitle }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -317,7 +317,7 @@ Lower weight gets higher precedence. So content with lower weight will come firs
{{< code file="layouts/partials/by-link-title.html" >}}
<ul>
<!-- ranges through content in ascending order according to the "linktitle" field in front matter. If a "linktitle" field is not set, the range will start with content that only has a "title" field and use that value for .LinkTitle -->
{{ range .Data.Pages.ByLinkTitle }}
{{ range .Pages.ByLinkTitle }}
<li>
<h1><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -332,7 +332,7 @@ Order based on the specified front matter parameter. Content that does not have
{{< code file="layouts/partials/by-rating.html" >}}
<!-- Ranges through content according to the "rating" field set in front matter -->
{{ range (.Data.Pages.ByParam "rating") }}
{{ range (.Pages.ByParam "rating") }}
<!-- ... -->
{{ end }}
{{< /code >}}
@ -340,7 +340,7 @@ Order based on the specified front matter parameter. Content that does not have
If the targeted front matter field is nested beneath another field, you can access the field using dot notation.
{{< code file="layouts/partials/by-nested-param.html" >}}
{{ range (.Data.Pages.ByParam "author.last_name") }}
{{ range (.Pages.ByParam "author.last_name") }}
<!-- ... -->
{{ end }}
{{< /code >}}
@ -351,7 +351,7 @@ Reversing order can be applied to any of the above methods. The following uses `
{{< code file="layouts/partials/by-date-reverse.html" >}}
<ul>
{{ range .Data.Pages.ByDate.Reverse }}
{{ range .Pages.ByDate.Reverse }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -368,7 +368,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
{{< code file="layouts/partials/by-page-field.html" >}}
<!-- Groups content according to content section. The ".Key" in this instance will be the section's title. -->
{{ range .Data.Pages.GroupBy "Section" }}
{{ range .Pages.GroupBy "Section" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -385,7 +385,7 @@ In the above example, you may want `{{.Title}}` to point the `title` field you h
{{< code file="layouts/partials/by-page-field.html" >}}
<!-- Groups content according to content section.-->
{{ range .Data.Pages.GroupBy "Section" }}
{{ range .Pages.GroupBy "Section" }}
<!-- Checks for existence of _index.md for a section; if available, pulls from "title" in front matter -->
{{ with $.Site.GetPage "section" .Key }}
<h3>{{.Title}}</h3>
@ -408,7 +408,7 @@ In the above example, you may want `{{.Title}}` to point the `title` field you h
{{< code file="layouts/partials/by-page-date.html" >}}
<!-- Groups content by month according to the "date" field in front matter -->
{{ range .Data.Pages.GroupByDate "2006-01" }}
{{ range .Pages.GroupByDate "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -425,7 +425,7 @@ In the above example, you may want `{{.Title}}` to point the `title` field you h
{{< code file="layouts/partials/by-page-publish-date.html" >}}
<!-- Groups content by month according to the "publishdate" field in front matter -->
{{ range .Data.Pages.GroupByPublishDate "2006-01" }}
{{ range .Pages.GroupByPublishDate "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -442,7 +442,7 @@ In the above example, you may want `{{.Title}}` to point the `title` field you h
{{< code file="layouts/partials/by-page-param.html" >}}
<!-- Groups content according to the "param_key" field in front matter -->
{{ range .Data.Pages.GroupByParam "param_key" }}
{{ range .Pages.GroupByParam "param_key" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -461,7 +461,7 @@ The following template takes grouping by `date` a step further and uses Go's lay
{{< code file="layouts/partials/by-page-param-as-date.html" >}}
<!-- Groups content by month according to the "param_key" field in front matter -->
{{ range .Data.Pages.GroupByParamDate "param_key" "2006-01" }}
{{ range .Pages.GroupByParamDate "param_key" "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -483,21 +483,21 @@ While these are logical defaults, they are not always the desired order. There a
#### 1. Adding the Reverse Method
```
{{ range (.Data.Pages.GroupBy "Section").Reverse }}
{{ range (.Pages.GroupBy "Section").Reverse }}
```
```
{{ range (.Data.Pages.GroupByDate "2006-01").Reverse }}
{{ range (.Pages.GroupByDate "2006-01").Reverse }}
```
#### 2. Providing the Alternate Direction
```
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
{{ range .Pages.GroupByDate "2006-01" "asc" }}
```
```
{{ range .Data.Pages.GroupBy "Section" "desc" }}
{{ range .Pages.GroupBy "Section" "desc" }}
```
### Order Within Groups
@ -511,7 +511,7 @@ Here is the ordering for the example that follows:
3. Pages within each respective group are ordered alphabetically according to the `title`.
{{< code file="layouts/partials/by-group-by-page.html" >}}
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
{{ range .Pages.GroupByDate "2006-01" "asc" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages.ByTitle }}
@ -536,8 +536,8 @@ Sometimes you only want to list a subset of the available content. A common is t
2. `key` *or* `field name`
3. `match value`
{{< code file="layouts/_default/.html" >}}
{{ range where .Data.Pages "Section" "post" }}
{{< code file="layouts/_default/index.html" >}}
{{ range where .Pages "Section" "post" }}
{{ .Content }}
{{ end }}
{{< /code >}}
@ -552,7 +552,7 @@ You can see more examples in the [functions documentation for `where`][wherefunc
2. `number of elements`
{{< code file="layout/_default/section.html" >}}
{{ range first 10 .Data.Pages }}
{{ range first 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
{{< /code >}}
@ -563,7 +563,7 @@ Using `first` and `where` together can be very powerful:
{{< code file="first-and-where-together.html" >}}
<!-- Orders the content inside the "posts" section by the "title" field and then ranges through only the first 5 posts -->
{{ range first 5 (where .Data.Pages "Section" "post").ByTitle }}
{{ range first 5 (where .Pages "Section" "post").ByTitle }}
{{ .Content }}
{{ end }}
{{< /code >}}

View File

@ -35,7 +35,7 @@ This list template is used for [spf13.com](http://spf13.com/). It makes use of [
<div>
<h1 id="title">{{ .Title }}</h1>
<ul id="list">
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "li"}}
{{ end }}
</ul>
@ -51,7 +51,7 @@ This list template is used for [spf13.com](http://spf13.com/). It makes use of [
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
@ -70,7 +70,7 @@ your list templates:
{{< code file="layouts/partials/order-default.html" >}}
<ul class="pages">
{{ range .Data.Pages }}
{{ range .Pages }}
<li>
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<time>{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
@ -82,7 +82,7 @@ your list templates:
### By Weight
{{< code file="layouts/partials/by-weight.html" >}}
{{ range .Data.Pages.ByWeight }}
{{ range .Pages.ByWeight }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -93,7 +93,7 @@ your list templates:
### By Date
{{< code file="layouts/partials/by-date.html" >}}
{{ range .Data.Pages.ByDate }}
{{ range .Pages.ByDate }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -104,7 +104,7 @@ your list templates:
### By Publish Date
{{< code file="layouts/partials/by-publish-date.html" >}}
{{ range .Data.Pages.ByPublishDate }}
{{ range .Pages.ByPublishDate }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .PublishDate.Format "Mon, Jan 2, 2006" }}</div>
@ -115,7 +115,7 @@ your list templates:
### By Expiration Date
{{< code file="layouts/partials/by-expiry-date.html" >}}
{{ range .Data.Pages.ByExpiryDate }}
{{ range .Pages.ByExpiryDate }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .ExpiryDate.Format "Mon, Jan 2, 2006" }}</div>
@ -126,7 +126,7 @@ your list templates:
### By Last Modified Date
{{< code file="layouts/partials/by-last-mod.html" >}}
{{ range .Data.Pages.ByLastmod }}
{{ range .Pages.ByLastmod }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -137,7 +137,7 @@ your list templates:
### By Length
{{< code file="layouts/partials/by-length.html" >}}
{{ range .Data.Pages.ByLength }}
{{ range .Pages.ByLength }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -149,7 +149,7 @@ your list templates:
### By Title
{{< code file="layouts/partials/by-title.html" >}}
{{ range .Data.Pages.ByTitle }}
{{ range .Pages.ByTitle }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -160,7 +160,7 @@ your list templates:
### By Link Title
{{< code file="layouts/partials/by-link-title.html" >}}
{{ range .Data.Pages.ByLinkTitle }}
{{ range .Pages.ByLinkTitle }}
<li>
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -175,7 +175,7 @@ Order based on the specified front matter parameter. Content that does not have
The below example sorts a list of posts by their rating.
{{< code file="layouts/partials/by-rating.html" >}}
{{ range (.Data.Pages.ByParam "rating") }}
{{ range (.Pages.ByParam "rating") }}
<!-- ... -->
{{ end }}
{{< /code >}}
@ -184,7 +184,7 @@ If the front matter field of interest is nested beneath another field, you can
also get it:
{{< code file="layouts/partials/by-nested-param.html" >}}
{{ range (.Data.Pages.ByParam "author.last_name") }}
{{ range (.Pages.ByParam "author.last_name") }}
<!-- ... -->
{{ end }}
{{< /code >}}
@ -194,7 +194,7 @@ also get it:
Reversing order can be applied to any of the above methods. The following uses `ByDate` as an example:
{{< code file="layouts/partials/by-date-reverse.html" >}}
{{ range .Data.Pages.ByDate.Reverse }}
{{ range .Pages.ByDate.Reverse }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
@ -209,7 +209,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
### By Page Field
{{< code file="layouts/partials/by-page-field.html" >}}
{{ range .Data.Pages.GroupBy "Section" }}
{{ range .Pages.GroupBy "Section" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -225,7 +225,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
### By Page date
{{< code file="layouts/partials/by-page-date.html" >}}
{{ range .Data.Pages.GroupByDate "2006-01" }}
{{ range .Pages.GroupByDate "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -241,7 +241,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
### By Page publish date
{{< code file="layouts/partials/by-page-publish-date.html" >}}
{{ range .Data.Pages.GroupByPublishDate "2006-01" }}
{{ range .Pages.GroupByPublishDate "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -257,7 +257,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
### By Page Param
{{< code file="layouts/partials/by-page-param.html" >}}
{{ range .Data.Pages.GroupByParam "param_key" }}
{{ range .Pages.GroupByParam "param_key" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -273,7 +273,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
### By Page Param in Date Format
{{< code file="layouts/partials/by-page-param-as-date.html" >}}
{{ range .Data.Pages.GroupByParamDate "param_key" "2006-01" }}
{{ range .Pages.GroupByParamDate "param_key" "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
@ -295,22 +295,22 @@ While these are logical defaults, they are not always the desired order. There a
#### Reverse Method
```
{{ range (.Data.Pages.GroupBy "Section").Reverse }}
{{ range (.Pages.GroupBy "Section").Reverse }}
```
```
{{ range (.Data.Pages.GroupByDate "2006-01").Reverse }}
{{ range (.Pages.GroupByDate "2006-01").Reverse }}
```
#### Provide the Alternate Direction
```
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
{{ range .Pages.GroupByDate "2006-01" "asc" }}
```
```
{{ range .Data.Pages.GroupBy "Section" "desc" }}
{{ range .Pages.GroupBy "Section" "desc" }}
```
### Order Within Groups
@ -321,7 +321,7 @@ In the following example, groups are ordered chronologically and then content
within each group is ordered alphabetically by title.
{{< code file="layouts/partials/by-group-by-page.html" >}}
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
{{ range .Pages.GroupByDate "2006-01" "asc" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages.ByTitle }}
@ -346,8 +346,8 @@ Sometimes you only want to list a subset of the available content. A common requ
2. `key` or `field name`
3. `match value`
{{< code file="layouts/_default/.html" >}}
{{ range where .Data.Pages "Section" "post" }}
{{< code file="layouts/_default/index.html" >}}
{{ range where .Pages "Section" "post" }}
{{ .Content }}
{{ end }}
{{< /code >}}
@ -360,7 +360,7 @@ Sometimes you only want to list a subset of the available content. A common requ
2. `number of elements`
{{< code file="layout/_default/section.html" >}}
{{ range first 10 .Data.Pages }}
{{ range first 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
{{< /code >}}
@ -370,7 +370,7 @@ Sometimes you only want to list a subset of the available content. A common requ
Using `first` and `where` together can be very powerful:
{{< code file="first-and-where-together.html" >}}
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ range first 5 (where .Pages "Section" "post") }}
{{ .Content }}
{{ end }}
{{< /code >}}

View File

@ -43,19 +43,19 @@ Setting `Paginate` to a positive value will split the list pages for the homepag
There are two ways to configure and use a `.Paginator`:
1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for *that page*.
2. Select a subset of the pages with the available template functions and ordering options, and pass the slice to `.Paginate`, e.g. `{{ range (.Paginate ( first 50 .Data.Pages.ByTitle )).Pages }}`.
2. Select a subset of the pages with the available template functions and ordering options, and pass the slice to `.Paginate`, e.g. `{{ range (.Paginate ( first 50 .Pages.ByTitle )).Pages }}`.
For a given **Page**, it's one of the options above. The `.Paginator` is static and cannot change once created.
The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:
* `{{ range (.Paginator 5).Pages }}`
* `{{ $paginator := .Paginate (where .Data.Pages "Type" "post") 5 }}`
* `{{ $paginator := .Paginate (where .Pages "Type" "post") 5 }}`
It is also possible to use the `GroupBy` functions in combination with pagination:
```
{{ range (.Paginate (.Data.Pages.GroupByDate "2006")).PageGroups }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
```
## Build the navigation
@ -75,7 +75,7 @@ If you use any filters or ordering functions to create your `.Paginator` *and* y
The following example shows how to create `.Paginator` before its used:
```
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ $paginator := .Paginate (where .Pages "Type" "post") }}
{{ template "_internal/pagination.html" . }}
{{ range $paginator.Pages }}
{{ .Title }}

View File

@ -42,7 +42,7 @@ The following is an example `robots.txt` layout:
{{< code file="layouts/robots.txt" download="robots.txt" >}}
User-agent: *
{{range .Data.Pages}}
{{range .Pages}}
Disallow: {{.RelPermalink}}
{{end}}
{{< /code >}}

View File

@ -73,7 +73,7 @@ This is the default RSS template that ships with Hugo. It adheres to the [RSS 2.
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range .Data.Pages }}
{{ range .Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>

View File

@ -41,7 +41,7 @@ This template respects the version 0.9 of the [Sitemap Protocol](http://www.site
```
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ range .Data.Pages }}
{{ range .Pages }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
@ -72,4 +72,4 @@ Defaults for `<changefreq>`, `<priority>` and `filename` values can be set in th
The same fields can be specified in an individual content file's front matter in order to override the value assigned to that piece of content at render time.
[pagevars]: /variables/page/
[pagevars]: /variables/page/

View File

@ -103,11 +103,11 @@ type WeightedPages []WeightedPage
## Displaying custom metadata in Taxonomy Terms Templates
If you need to display custom metadata for each taxonomy term, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in it's front matter, [as explained in the taxonomies documentation](/content-management/taxonomies/#add-custom-meta-data-to-a-taxonomy-term). Based on the Actors taxonomy example shown there, within your taxonomy terms template, you may access your custom fields by iterating through the variable `.Data.Pages` as such:
If you need to display custom metadata for each taxonomy term, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in it's front matter, [as explained in the taxonomies documentation](/content-management/taxonomies/#add-custom-meta-data-to-a-taxonomy-term). Based on the Actors taxonomy example shown there, within your taxonomy terms template, you may access your custom fields by iterating through the variable `.Pages` as such:
```
<ul>
{{ range .Data.Pages }}
{{ range .Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
{{ .Params.wikipedia }}

View File

@ -51,14 +51,14 @@ This will print out a list of all the variables scoped to the current context
When developing a [homepage][], what does one of the pages you're looping through look like?
```
{{ range .Data.Pages }}
{{ range .Pages }}
{{/* The context, ".", is now each one of the pages as it goes through the loop */}}
{{ printf "%#v" . }}
{{ end }}
```
{{% note "`.Data.Pages` on the Homepage" %}}
`.Data.Pages` on the homepage is equivalent to `.Site.Pages`.
{{% note "`.Pages` on the Homepage" %}}
`.Pages` on the homepage is equivalent to `.Site.Pages`.
{{% /note %}}
## Why Am I Showing No Defined Variables?
@ -78,4 +78,4 @@ This example will render the header partial, but the header partial will not hav
The dot (`.`) is considered fundamental to understanding Hugo templating. For more information, see [Introduction to Hugo Templating][tempintro].
[homepage]: /templates/homepage/
[tempintro]: /templates/introduction/
[tempintro]: /templates/introduction/

View File

@ -73,7 +73,7 @@ In this example, `.Render` is passed into the template to call the [render funct
<main id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
{{ .Render "summary"}}
{{ end }}
</div>

View File

@ -106,7 +106,9 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
: contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).)
.Pages
: a collection of associated pages. This value will be `nil` for regular content pages. `.Pages` is an alias for `.Data.Pages`.
: a collection of associated pages. `.Pages` is an alias for
`.Data.Pages`. This value will be `nil` within the context of
regular content pages.
.Permalink
: the Permanent link for this page; see [Permalinks](/content-management/urls/)

View File

@ -90,7 +90,7 @@ From the above base template, you can define a [default list template][hugolists
{{< code file="layouts/_default/list.html" download="list.html" >}}
{{ define "main" }}
<h1>Posts</h1>
{{ range .Data.Pages }}
{{ range .Pages }}
<article>
<h2>{{ .Title }}</h2>
{{ .Content }}