From 884713fc2a80f53ee21a225ca1d101e1d1ce336c Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Mon, 26 Sep 2016 08:32:46 +0300 Subject: [PATCH] layouts: Add theme support for categories and tags Add categories/tags to front matter and they will be displayed on summary and post pages, with links to taxonomy pages. Example: +++ date = "2016-09-24T21:28:31+03:00" title = "Post title" categories = ["Nature"] tags = ["Wetland", "Oasis"] +++ For some reason if you add tags singularly, like: categories = "Nature" you get index errors from Hugo. Not sure if I need to parse the tags differently or just add more logic to test if the terms are singular or not. --- layouts/_default/single.html | 2 +- layouts/_default/summary.html | 2 +- layouts/partials/meta-terms.html | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/meta-terms.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 130a81a..1c1b54a 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -3,7 +3,7 @@

{{ .Title }}

- +
{{ .Content }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 8b35c72..9ca1292 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -1,7 +1,7 @@

{{ .Title }}

- +
{{ .Summary }} Read more → diff --git a/layouts/partials/meta-terms.html b/layouts/partials/meta-terms.html new file mode 100644 index 0000000..0f514a8 --- /dev/null +++ b/layouts/partials/meta-terms.html @@ -0,0 +1,6 @@ +{{ if .Params.categories }} +  {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}{{ . }}{{ end }} +{{ end }} +{{ if .Params.tags }} +  {{ range $index, $tag := .Params.tags }}{{ if gt $index 0 }}, {{ end }}{{ end }} +{{ end }}