docs: Revise docs to reflect that Node is gone

Updates #2297
This commit is contained in:
Bjørn Erik Pedersen 2016-11-20 23:00:57 +01:00
parent ae1de7abb1
commit aafbd3b4bf
16 changed files with 68 additions and 109 deletions

View file

@ -190,9 +190,9 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
```html
<ul>
{{- $currentNode := . -}}
{{- $current := . -}}
{{ range .Site.Menus.main -}}
<li class="{{ if $currentNode.IsMenuCurrent "main" . }}active{{ end }}">
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
</li>
{{- end }}

View file

@ -36,7 +36,7 @@ Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> exactly
## Showing Summaries
You can show content summaries with the following code. You could do this, for example, on a [list](/templates/list/) node.
You can show content summaries with the following code. You could do this, for example, on a [list](/templates/list/) page.
{{ range first 10 .Data.Pages }}
<div class="summary">

View file

@ -162,11 +162,11 @@ The following is an example:
<div id="sidebar" class="nav-collapse">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
{{ $currentNode := . }}
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="sub-menu{{if $currentNode.HasMenuCurrent "main" . }} active{{end}}">
<li class="sub-menu{{if $currentPage.HasMenuCurrent "main" . }} active{{end}}">
<a href="javascript:;" class="">
{{ .Pre }}
<span>{{ .Name }}</span>
@ -174,7 +174,7 @@ The following is an example:
</a>
<ul class="sub">
{{ range .Children }}
<li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}"> {{ .Name }} </a> </li>
<li{{if $currentPage.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}"> {{ .Name }} </a> </li>
{{ end }}
</ul>
{{else}}
@ -210,9 +210,9 @@ This will create a menu with all the sections as menu items and all the sections
```
<nav class="sidebar-nav">
{{ $currentNode := . }}
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<a class="sidebar-nav-item{{if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }} active{{end}}" href="{{.URL}}">{{ .Name }}</a>
<a class="sidebar-nav-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{.URL}}">{{ .Name }}</a>
{{ end }}
</nav>

View file

@ -27,14 +27,14 @@ Setting `Paginate` to a positive value will split the list pages for the home pa
## List the pages
**A `.Paginator` is provided to help building a pager menu. This is only relevant for the templates for the home page and the list pages (sections and taxonomies).**
**A `.Paginator` is provided to help building a pager menu. This is currently only relevant for the templates for the home page and the list pages (sections and taxonomies).**
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 sub-set 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 }}`.
For a given **Node**, it's one of the options above. The `.Paginator` is static and cannot change once created.
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:

View file

@ -12,9 +12,9 @@ title: Scratch
weight: 80
---
`Scratch` -- a "scratchpad" for your node- or page-scoped variables. In most cases you can do well without `Scratch`, but there are some use cases that aren't solvable with Go's templates without `Scratch`'s help, due to scoping issues.
`Scratch` -- a "scratchpad" for your page-scoped variables. In most cases you can do well without `Scratch`, but there are some use cases that aren't solvable with Go's templates without `Scratch`'s help, due to scoping issues.
`Scratch` is added to both `Node` and `Page` and `Shortcode` -- with following methods:
`Scratch` is added to both `Page` and `Shortcode` -- with following methods:
* `Set` and `Add` takes a `key` and the `value` to add.
* `Get` returns the `value` for the `key` given.
@ -25,7 +25,7 @@ weight: 80
For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
The scope of the backing data is global for the given `Node`, `Page` or `Shortcode`, and spans partial and shortcode includes.
The scope of the backing data is global for the given `Page` or `Shortcode`, and spans partial and shortcode includes.
Note that `.Scratch` from a shortcode will return the shortcode's `Scratch`, which in most cases is what you want. If you want to store it in the page scroped Scratch, then use `.Page.Scratch`.

View file

@ -20,10 +20,10 @@ your own template for a [custom 404 error page](https://help.github.com/articles
by creating a 404.html template file in your `/layouts` folder.
When Hugo generates your site, the `404.html` file will be placed in the root.
404 pages are of the type **"node"** and have all the [node
404 pages will have all the regular [page
variables](/layout/variables/) available to use in the templates.
In addition to the standard node variables, the 404 page has access to
In addition to the standard page variables, the 404 page has access to
all site content accessible from `.Data.Pages`.
▾ layouts/

View file

@ -20,13 +20,6 @@ Here are some snippets you can add to your template to answer some common questi
These snippets use the `printf` function available in all Go templates. This function is
an alias to the Go function, [fmt.Printf](http://golang.org/pkg/fmt/).
### What type of page is this?
Does Hugo consider this page to be a "Node" or a "Page"? (Put this snippet at
the top level of your template. Don't use it inside of a `range` loop.)
{{ printf "%T" . }}
### What variables are available in this context?
@ -35,8 +28,7 @@ from anywhere in your template. This will print out all the values under, `.Sit
{{ printf "%#v" $.Site }}
This will print out the value of `.Permalink`, which is available on both Nodes
and Pages.
This will print out the value of `.Permalink`:
{{ printf "%#v" .Permalink }}

View file

@ -831,7 +831,7 @@ The above also exploits the fact that the Go template parser JSON-encodes object
### ref, relref
Looks up a content page by relative path or logical name to return the permalink (`ref`) or relative permalink (`relref`). Requires a Node or Page object (usually satisfied with `.`). Used in the [`ref` and `relref` shortcodes]({{% ref "extras/crossreferences.md" %}}).
Looks up a content page by relative path or logical name to return the permalink (`ref`) or relative permalink (`relref`). Requires a `Page` object (usually satisfied with `.`). Used in the [`ref` and `relref` shortcodes]({{% ref "extras/crossreferences.md" %}}).
e.g. {{ ref . "about.md" }}

View file

@ -65,8 +65,7 @@ Accessing the Page Parameter "bar"
## Variables
Each Go template has a struct (object) made available to it. In Hugo, each
template is passed either a page or a node struct depending on which type of
page you are rendering. More details are available on the
template is passed page struct. More details are available on the
[variables](/layout/variables/) page.
A variable is accessed by referencing the variable name.

View file

@ -16,7 +16,7 @@ weight: 50
The home page of a website is often formatted differently than the other
pages. In Hugo you can define your own homepage template.
Homepage is of the type "node" and have all the [node
Homepage is a `Page` and have all the [page
variables](/templates/variables/) and [site
variables](/templates/variables/) available to use in the templates.
@ -24,7 +24,7 @@ variables](/templates/variables/) available to use in the templates.
bootstrapping a new site and template. It is also the only required
template when using a single page site.*
In addition to the standard node variables, the homepage has access to
In addition to the standard page variables, the homepage has access to
all site content accessible from `.Data.Pages`. Details on how to use the
list of pages can be found in the [Lists Template](/templates/list/).

View file

@ -93,7 +93,7 @@ can have different RSS files for each section and taxonomy.
## Variables
List pages are of the type "node" and have all the [node variables](/templates/variables/)
A list page is a `Page` and have all the [page variables](/templates/variables/)
and [site variables](/templates/variables/) available to use in the templates.
Taxonomy pages will additionally have:

View file

@ -34,9 +34,6 @@ like good names to use for inclusion in your other templates.
header.html
footer.html
By ensuring that we only reference [variables](/layout/variables/)
used for both nodes and pages, we can use the same partials for both.
## Partial vs Template
Version v0.12 of Hugo introduced the `partial` call inside the template system.

View file

@ -19,7 +19,7 @@ Like all other templates, you can use a single RSS template to generate all of y
*Unlike other Hugo templates*, Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320). In most cases this will be sufficient, and an RSS template will not need to be provided by the user. But you can provide an rss template if you like, as you can see in the next section.
RSS pages are of the **type "node"** and have all the [node variables](/layout/variables/) available to use in the templates.
RSS pages are of the type `Page` and have all the [page variables](/layout/variables/) available to use in the templates.
## Which Template will be rendered?
Hugo uses a set of rules to figure out which template to use when rendering a specific page.

View file

@ -18,7 +18,7 @@ A single Sitemap template is used to generate the `sitemap.xml` file.
Hugo automatically comes with this template file. **No work is needed on
the users' part unless they want to customize `sitemap.xml`.**
This page is of the type "node" and have all the [node
A sitemap is a `Page` and have all the [page
variables](/layout/variables/) available to use in this template
along with Sitemap-specific ones:
@ -26,9 +26,6 @@ along with Sitemap-specific ones:
**.Sitemap.Priority** The priority of the page<br>
**.Sitemap.Filename** The sitemap filename<br>
In addition to the standard node variables, the homepage has access to all
site pages through `.Data.Pages`.
If provided, Hugo will use `/layouts/sitemap.xml` instead of the internal
one.

View file

@ -46,8 +46,8 @@ dedicated page for the terms.
## Variables
Taxonomy Terms pages are of the type "node" and have all the
[node variables](/templates/variables/) and
Taxonomy Terms pages are of the type `Page` and have all the
[page variables](/templates/variables/) and
[site variables](/templates/variables/)
available to use in the templates.
@ -63,11 +63,6 @@ The last two can also be reversed: **.Data.Terms.Alphabetical.Reverse**, **.Data
### Example terms.html files
List pages are of the type "node" and have all the
[node variables](/templates/variables/) and
[site variables](/templates/variables/)
available to use in the templates.
This content template is used for [spf13.com](http://spf13.com/).
It makes use of [partial templates](/templates/partials/). The list of taxonomy
templates cannot use a [content view](/templates/views/) as they don't display the content, but

View file

@ -26,41 +26,50 @@ matter, content or derived from file location.
**See also:** [Scratch](/extras/scratch) for page-scoped writable variables.
**.Title** The title for the content.<br>
**.Content** The content itself, defined below the front matter.<br>
**.Summary** A generated summary of the content for easily showing a snippet in a summary view. Note that the breakpoint can be set manually by inserting <code>&lt;!&#x2d;&#x2d;more&#x2d;&#x2d;&gt;</code> at the appropriate place in the content page. See [Summaries](/content/summaries/) for more details.<br>
**.Truncated** A boolean, `true` if the `.Summary` is truncated. Useful for showing a "Read more..." link only if necessary. See [Summaries](/content/summaries/) for more details.<br>
**.Description** The description for the content.<br>
**.Keywords** The meta keywords for this content.<br>
**.Date** The date the content is associated with.<br>
**.Lastmod** The date the content was last modified.<br>
**.PublishDate** The date the content is published on.<br>
**.ExpiryDate** The date where the content is scheduled to expire on.<br>
**.Type** The content [type](/content/types/) (e.g. post).<br>
**.Section** The [section](/content/sections/) this content belongs to.<br>
**.Permalink** The Permanent link for this page.<br>
**.RelPermalink** The Relative permanent link for this page.<br>
**.LinkTitle** Access when creating links to this content. Will use `linktitle` if set in front matter, else `title`.<br>
**.RSSLink** Link to the taxonomies' RSS link.<br>
**.TableOfContents** The rendered table of contents for this content.<br>
**.Prev** Pointer to the previous content (based on pub date).<br>
**.Next** Pointer to the following content (based on pub date).<br>
**.PrevInSection** Pointer to the previous content within the same section (based on pub date). For example, `{{if .PrevInSection}}{{.PrevInSection.Permalink}}{{end}}`.<br>
**.NextInSection** Pointer to the following content within the same section (based on pub date)<br>
**.FuzzyWordCount** The approximate number of words in the content.<br>
**.WordCount** The number of words in the content.<br>
**.ReadingTime** The estimated time it takes to read the content in minutes.<br>
**.Weight** Assigned weight (in the front matter) to this content, used in sorting.<br>
**.RawContent** Raw Markdown content without the metadata header. Useful with [remarkjs.com](http://remarkjs.com)<br>
**.UniqueID** The MD5-checksum of the page's filename<br>
**.Data** The data specific to this type of page.<br>
**.Date** The date the page is associated with.<br>
**.Description** The description for the page.<br>
**.Draft** A boolean, `true` if the content is marked as a draft in the front matter.<br>
**.IsNode** Always false for pages.<br>
**.IsPage** Always true for page.<br>
**.Site** See [Site Variables]({{< relref "#site-variables" >}}) below.<br>
**.ExpiryDate** The date where the content is scheduled to expire on.<br>
**.FuzzyWordCount** The approximate number of words in the content.<br>
**.Hugo** See [Hugo Variables]({{< relref "#hugo-variables" >}}) below.<br>
**.Translations** A list of translated versions of the current page. See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info. Note that the `Translation` variable is also available on node, e.g. home page etc. <br>
**.IsHome** True if this is the home page.<br>
**.IsNode** Always false for regular content pages.<br>
**.IsPage** Always true for regular content pages.<br>
**.IsTranslated** Whether there are any translations to display.<br>
**.Lang** Language taken from the language extension notation. <br>
**.Keywords** The meta keywords for this content.<br>
**.Kind** What *kind* of page is this: is one of *page, home, section, taxonomy or taxonomyTerm.* There are also *RSS, sitemap, robotsTXT and 404*, but these will only available during rendering of that kind of page, and not available in any of the `Pages` collections.<br>
**.Lang** Language taken from the language extension notation.<br>
**.Language** A language object that points to this the language's definition in the site config.
**.Lastmod** The date the content was last modified.<br>
**.LinkTitle** Access when creating links to this content. Will use `linktitle` if set in front matter, else `title`.<br>
**.Next** Pointer to the following content (based on pub date).<br>
**.NextInSection** Pointer to the following content within the same section (based on pub date)<br>
**.Permalink** The Permanent link for this page.<br>
**.Prev** Pointer to the previous content (based on pub date).<br>
**.PrevInSection** Pointer to the previous content within the same section (based on pub date). For example, `{{if .PrevInSection}}{{.PrevInSection.Permalink}}{{end}}`.<br>
**.PublishDate** The date the content is published on.<br>
**.RSSLink** Link to the taxonomies' RSS link.<br>
**.RawContent** Raw Markdown content without the metadata header. Useful with [remarkjs.com](http://remarkjs.com)<br>
**.ReadingTime** The estimated time it takes to read the content in minutes.<br>
**.Ref(ref)** Returns the permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments correctly.<br>
**.RelPermalink** The Relative permanent link for this page.<br>
**.RelRef(ref)** Returns the relative permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments
**.Section** The [section](/content/sections/) this content belongs to.<br>
**.Site** See [Site Variables]({{< relref "#site-variables" >}}) below.<br>
**.Summary** A generated summary of the content for easily showing a snippet in a summary view. Note that the breakpoint can be set manually by inserting <code>&lt;!&#x2d;&#x2d;more&#x2d;&#x2d;&gt;</code> at the appropriate place in the content page. See [Summaries](/content/summaries/) for more details.<br>
**.TableOfContents** The rendered table of contents for this content.<br>
**.Title** The title for this page.<br>
**.Translations** A list of translated versions of the current page. See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info.<br>
**.Truncated** A boolean, `true` if the `.Summary` is truncated. Useful for showing a "Read more..." link only if necessary. See [Summaries](/content/summaries/) for more details.<br>
**.Type** The content [type](/content/types/) (e.g. post).<br>
**.URL** The relative URL for this page. Note that if `URL` is set directly in frontmatter, that URL is returned as-is.<br>
**.UniqueID** The MD5-checksum of the page's filename<br>
**.Weight** Assigned weight (in the front matter) to this content, used in sorting.<br>
**.WordCount** The number of words in the content.<br>
## Page Params
@ -94,40 +103,12 @@ which would render
### Param method
In Hugo you can declare params both for the site and the individual page. A common use case is to have a general value for the site and a more specific value for some of the pages (i.e. an image).
With the `Param` method the most specific value will be selected for you, and it is safe to use it in any template (it's defined on both Page and Node):
```
$.Param "image"
```
### Taxonomy Terms Page Variables
## Node Variables
In Hugo, a node is any page not rendered directly by a content file. This
includes taxonomies, lists and the homepage.
**See also:** [Scratch](/extras/scratch) for global node variables.
**.Title** The title for the content.<br>
**.Date** The date the content is published on.<br>
**.Lastmod** The date the content was last modified.<br>
**.Permalink** The Permanent link for this node<br>
**.URL** The relative URL for this node.<br>
**.Ref(ref)** Returns the permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments correctly.<br>
**.RelRef(ref)** Returns the relative permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments correctly.<br>
**.RSSLink** Link to the taxonomies' RSS link.<br>
**.Data** The data specific to this type of node.<br>
**.IsHome** True if the node is the site home page.<br>
**.IsNode** Always true for nodes.<br>
**.IsPage** Always false for nodes.<br>
**.Site** See [Site Variables]({{< relref "#site-variables" >}}) below.<br>
**.Hugo** See [Hugo Variables]({{< relref "#hugo-variables" >}}) below.<br>
**.Translations** A list of translated versions of the current node. All nodes (except the pager nodes) can have translated counter parts. See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info. <br>
**.IsTranslated** Whether there are any translations to display.<br>
**.Lang** The language code of this node.<br>
### Taxonomy Terms Node Variables
[Taxonomy Terms](/templates/terms/) pages are of the type "node" and have the following additional variables. These are available in `layouts/_defaults/terms.html` for example.
[Taxonomy Terms](/templates/terms/) pages are of the type `Page` and have the following additional variables. These are available in `layouts/_defaults/terms.html` for example.
**.Data.Singular** The singular name of the taxonomy<br>
**.Data.Plural** The plural name of the taxonomy<br>
@ -146,8 +127,6 @@ The **.Site.Taxonomies** variable holds all taxonomies defines site-wide. It is
The Taxonomy variable, available as **.Site.Taxonomies.tags** for example, contains the list of tags (values) and, for each of those, their corresponding content pages.
## Site Variables
Also available is `.Site` which has the following:
@ -189,7 +168,7 @@ Also available is `.Site` which has the following:
The `.File` variable gives you additional information of a page.
> **Note:** `.File` is only accessible on *Pages* but **not** on *Nodes* (like the homepage and list pages).
> **Note:** `.File` is only accessible on *Pages* that has a content page attached to it.
Available are the following attributes: