From 817d69487cbe58d38b8b13312c203fba42817bcf Mon Sep 17 00:00:00 2001 From: Renato Vargas Date: Fri, 29 Jan 2016 16:43:29 -0600 Subject: [PATCH] Expanded the Page Params section in variables.md Expanded on the use of Page Params in the templates/variables.md documentation. Added sample code for something that keeps coming up on discuss.github.io --- docs/content/templates/variables.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index d656ddd21..18e933f5d 100644 --- a/docs/content/templates/variables.md +++ b/docs/content/templates/variables.md @@ -67,6 +67,26 @@ For example, the *tags* and *categories* taxonomies are accessed with: **All Params are only accessible using all lowercase characters.** +This is particularly useful for the introduction of user defined fields in content files. For example, a Hugo website on book reviews could have in the front matter of /content/review/book01.md + + --- + ... + affiliatelnk: "http://www.my-book-link.here" + recommendedby: "my Mother" + --- + +Which would then be accessible to a template at /theme/yourtheme/review/single.html, for example, through .Params.affiliatelnk and .Params.recommendedby, respectively. Two common situations where these could be introduced are as a value of a certain attribute (like href="" below) or by itself if it will be displayed. Sample syntaxes include: + +

Buy this book

+

It was recommended by {{ .Params.recommendedby }}.

+ +which would render + +

Buy this book

+

It was recommended by my Mother.

+ +**See also:** [cross-references]({{% ref "content/archetypes.md" %}}) for consistency of `Params` accross pieces of content. + ### 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).