diff --git a/content/templates/single-page-templates.md b/content/templates/single-page-templates.md index d0b210991..123132cc6 100644 --- a/content/templates/single-page-templates.md +++ b/content/templates/single-page-templates.md @@ -43,11 +43,11 @@ Hugo assumes your content section and content type are the same unless you tell ## Example Single Page Templates -Content pages are of the type `page` and will therefore have all the [page variables][] and [site variables][] available to use in their templates. +Content pages are of the type `page` and will therefore have all the [page variables][pagevars] and [site variables][] available to use in their templates. ### `post/single.html` -This single page template is a modified version of one used for for [spf13.com][spf13]. It makes use of [base templates][]: +This single page template makes use of Hugo [base templates][], the [`.Format` function][] for dates, the [`.WordCount` page variable][pagevars], and ranges through the single content's specific [taxonomies][pagetaxonomy]. [`with`][] is also used to check whether the taxonomies are set in the front matter. {{% code file="layouts/post/single.html" download="single.html" %}} ```html @@ -64,7 +64,7 @@ This single page template is a modified version of one used for for [spf13.com][

{{ .Date.Format "Mon Jan 2, 2006" }}

-
{{ .FuzzyWordCount }} Words
+
{{ .WordCount }} Words
{{ with .Params.topics }}
- {{ with .Prev }} + {{ with .PrevInSection }} {{ end }} - {{ with .Next }} + {{ with .NextInSection }} {{ end }}
@@ -94,54 +94,6 @@ This single page template is a modified version of one used for for [spf13.com][ ``` {{% /code %}} -### `project/single.html` - -This single page template is also modified from an existing template for [spf13.com][spf13] and makes use of [base templates][]: - -{{% code file="project/single.html" download="single.html" %}} -```html -{{ define "main" }} -
-

{{ .Title }}

-
-
- {{ .Content }} -
-
-
- - {{with .Params "project_url" }} -
- Fork me on GitHub -
- {{ end }} -{{ end }} -``` -{{% /code %}} - -Notice how `project/single.html` uses an additional parameter unique to this template (i.e., `project_url`). This doesn't need to be defined ahead of time. The use of [`with`](/functions/with) means the key can be used in the template only if set in the content file's front matter. - To easily generate new instances of a content type (e.g., new `.md` files in a section like `project/`) with preconfigured front matter, use [content archetypes][archetypes]. [archetypes]: /content-management/archetypes/ @@ -150,9 +102,12 @@ To easily generate new instances of a content type (e.g., new `.md` files in a s [content type]: /content-management/types/ [directory structure]: /getting-started/directory-structure/ [dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself +[`.Format` function]: /functions/format/ [front matter]: /content-management/front-matter/ -[page variables]: /variables/page/ +[pagetaxonomy]: /templates/taxonomy-templates/#displaying-a-single-piece-of-content-s-taxonomies +[pagevars]: /variables/page/ [partials]: /templates/partials/ [section]: /content-management/sections/ [site variables]: /variables/site/ -[spf13]: http://spf13.com/ \ No newline at end of file +[spf13]: http://spf13.com/ +[`with`]: /functions/with/ \ No newline at end of file diff --git a/content/templates/taxonomy-templates.md b/content/templates/taxonomy-templates.md index 405c0cb53..3b5d454b7 100644 --- a/content/templates/taxonomy-templates.md +++ b/content/templates/taxonomy-templates.md @@ -203,7 +203,7 @@ using the [list templates](/templates/list/): 3. You can list all terms for a taxonomy 4. You can list all taxonomies (with their terms) -### Displaying a Single Piece of Content's Taxonomies +## Displaying a Single Piece of Content's Taxonomies Within your content templates, you may wish to display the taxonomies that piece of content is assigned to.