Skip to content
Permalink
Browse files

Replace .Data.Pages with .Pages

  • Loading branch information...
kaushalmodi authored and bep committed Jul 16, 2018
1 parent 85d3712 commit 50df8bfb8371a0fcd13e4ad63284150ec720a257
@@ -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 }}
@@ -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>
@@ -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/
@@ -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>
@@ -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>
@@ -21,8 +21,7 @@ aliases: []


```
{{ range first 10 .Data.Pages }}
{{ range first 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
```

@@ -23,8 +23,7 @@ aliases: []


```
{{ range last 10 .Data.Pages }}
{{ range last 10 .Pages }}
{{ .Render "summary" }}
{{ end }}
```

@@ -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 }}
```
@@ -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 }}
```
@@ -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/
@@ -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 }}
@@ -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>
@@ -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 -->
Oops, something went wrong.

0 comments on commit 50df8bf

Please sign in to comment.
You can’t perform that action at this time.