From 667e11c4ec3835d959aab1797647bd0a49869674 Mon Sep 17 00:00:00 2001 From: etienne Date: Tue, 21 Oct 2014 23:35:24 +0200 Subject: Init commit --- content/templates/variables.md | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 content/templates/variables.md (limited to 'content/templates/variables.md') diff --git a/content/templates/variables.md b/content/templates/variables.md new file mode 100644 index 0000000..f7a202b --- /dev/null +++ b/content/templates/variables.md @@ -0,0 +1,82 @@ +--- +aliases: +- /doc/variables/ +- /layout/variables/ +date: 2013-07-01 +linktitle: Variables +menu: + main: + parent: layout +next: /templates/content +prev: /templates/functions +title: Template Variables +weight: 20 +--- + +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. + +## Page Variables + +The following is a list of most of the accessible variables which can be +defined for a piece of content. Many of these will be defined in the front +matter, content or derived from file location. + +**.Title** The title for the content.
+**.Content** The content itself, defined below the front matter.
+**.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 *<!--more-->* at the appropriate place in the content page.
+**.Description** The description for the content.
+**.Keywords** The meta keywords for this content.
+**.Date** The date the content is associated with.
+**.PublishDate** The date the content is published on.
+**.Type** The content [type](/content/types/) (e.g. post)
+**.Section** The [section](/content/sections/) this content belongs to
+**.Permalink** The Permanent link for this page.
+**.RelPermalink** The Relative permanent link for this page.
+**.LinkTitle** Access when creating links to this content. Will use linktitle if set in front-matter, else title
+**.Taxonomies** These will use the field name of the plural form of the index (see tags and categories above)
+**.RSSLink** Link to the indexes' rss link
+**.TableOfContents** The rendered table of contents for this content
+**.Prev** Pointer to the previous content (based on pub date)
+**.Next** Pointer to the following content (based on pub date)
+**.FuzzyWordCount** The approximate number of words in the content.
+**.WordCount** The number of words in the content.
+**.ReadingTime** The estimated time it takes to read the content in minutes.
+**.Weight** Assigned weight (in the front matter) to this content, used in sorting.
+**.IsNode** Always false for pages.
+**.IsPage** Always true for page.
+**.Site** See site variables below
+ +## Page Params + +Any other value defined in the front matter, including indexes will be made available under `.Params`. +Take for example I'm using tags and categories as my indexes. The following would be how I would access them: + +**.Params.tags**
+**.Params.categories**
+
+**All Params are only accessible using all lowercase characters**
+ +## 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.
+**.Date** The date the content is published on.
+**.Permalink** The Permanent link for this node
+**.Url** The relative url for this node.
+**.RSSLink** Link to the indexes' rss link
+**.Data** The data specific to this type of node.
+**.IsNode** Always true for nodes.
+**.IsPage** Always false for nodes.
+**.Site** See site variables below
+ +## Site Variables + +Also available is `.Site` which has the following: + +**.Site.BaseUrl** The base URL for the site as defined in the config.json file.
+**.Site.Taxonomies** The indexes for the entire site.
+**.Site.LastChange** The date of the last change of the most recent content.
+**.Site.Recent** Array of all content ordered by Date, newest first.
+**.Site.Params** A container holding the values from `params` in your site configuration file.
-- cgit v1.3