2013-07-06 23:36:30 +00:00
|
|
|
---
|
|
|
|
title: "Variables"
|
2013-08-17 12:34:25 +00:00
|
|
|
date: "2013-07-01"
|
|
|
|
aliases: ["/doc/variables/"]
|
2013-10-26 06:18:14 +00:00
|
|
|
groups: ["layout"]
|
|
|
|
groups_weight: 20
|
2013-07-08 21:57:01 +00:00
|
|
|
---
|
2013-07-04 15:32:55 +00:00
|
|
|
|
|
|
|
Hugo makes a set of values available to the templates. Go templates are context based. The following
|
|
|
|
are available in the context for the templates.
|
|
|
|
|
2013-08-17 12:34:25 +00:00
|
|
|
## Page Variables
|
|
|
|
|
2013-08-08 23:13:03 +00:00
|
|
|
**.Title** The title for the content.<br>
|
2013-07-04 15:32:55 +00:00
|
|
|
**.Description** The description for the content.<br>
|
|
|
|
**.Keywords** The meta keywords for this content.<br>
|
|
|
|
**.Date** The date the content is published on.<br>
|
|
|
|
**.Indexes** These will use the field name of the plural form of the index (see tags and categories above)<br>
|
|
|
|
**.Permalink** The Permanent link for this page.<br>
|
2013-10-25 22:37:53 +00:00
|
|
|
**.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>
|
2013-07-04 15:32:55 +00:00
|
|
|
**.FuzzyWordCount** The approximate number of words in the content.<br>
|
|
|
|
**.RSSLink** Link to the indexes' rss link <br>
|
2013-08-03 07:30:34 +00:00
|
|
|
**.Prev** Pointer to the previous content (based on pub date)<br>
|
|
|
|
**.Next** Pointer to the following content (based on pub date)<br>
|
2013-08-17 12:34:25 +00:00
|
|
|
**.Site** See site variables below<br>
|
2013-08-08 23:13:03 +00:00
|
|
|
**.Content** The content itself, defined below the front matter.<br>
|
2013-08-29 12:22:19 +00:00
|
|
|
**.Summary** A generated summary of the content for easily showing a snippet in a summary view.<br>
|
2013-07-04 15:32:55 +00:00
|
|
|
|
2013-08-17 12:34:25 +00:00
|
|
|
Any value defined in the front matter, including indexes will be made available under `.Params`.
|
2013-07-04 15:32:55 +00:00
|
|
|
Take for example I'm using tags and categories as my indexes. The following would be how I would access them:
|
|
|
|
|
2013-08-17 12:34:25 +00:00
|
|
|
**.Params.Tags** <br>
|
|
|
|
**.Params.Categories** <br>
|
|
|
|
|
|
|
|
## Node Variables
|
|
|
|
In Hugo a node is any page not rendered directly by a content file. This
|
|
|
|
includes indexes, lists and the homepage.
|
|
|
|
|
|
|
|
**.Title** The title for the content.<br>
|
|
|
|
**.Date** The date the content is published on.<br>
|
|
|
|
**.Data** The data specific to this type of node.<br>
|
|
|
|
**.Permalink** The Permanent link for this node<br>
|
|
|
|
**.Url** The relative url for this node.<br>
|
|
|
|
**.RSSLink** Link to the indexes' rss link <br>
|
|
|
|
**.Site** See site variables below<br>
|
|
|
|
|
|
|
|
## Site Variables
|
2013-07-04 15:32:55 +00:00
|
|
|
|
|
|
|
Also available is `.Site` which has the following:
|
|
|
|
|
|
|
|
**.Site.BaseUrl** The base URL for the site as defined in the config.json file.<br>
|
2013-10-25 22:37:53 +00:00
|
|
|
**.Site.Indexes** The indexes for the entire site.<br>
|
2013-07-04 15:32:55 +00:00
|
|
|
**.Site.LastChange** The date of the last change of the most recent content.<br>
|
2013-11-18 23:31:02 +00:00
|
|
|
**.Site.Recent** Array of all content ordered by Date, newest first.<br>
|
|
|
|
**.Site.Params** A container holding the values from `params` in your site configuration file.<br>
|