From 26d99396982cc626e6e43df4644d8e5a4e9af0f6 Mon Sep 17 00:00:00 2001 From: Paul Maddern Date: Mon, 4 Mar 2024 10:58:08 +0000 Subject: [PATCH] Allows use of categories and tags I probably wouldn't handle it like this if I were writing it from scratch, but this is a suggested solution for having both tags _and_ categories present on the site. ``` --- title: "Wheelie" date: 2024-03-01T22:06:25Z draft: false tags: ["skoolkit", "wheelie", "zx spectrum", "z80"] categories: - "Disassembly" --- ``` The problem is, categories are defined by default so you end up with an empty page; e.g. https://meik2333.com/categories/ The alternative is to remove it, which can be done ``` [Taxonomies] tag = "tags" ``` (If you don't define `category = "categories"` then it's removed). --- layouts/partials/tags.html | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/layouts/partials/tags.html b/layouts/partials/tags.html index d4eaed4..1a8f2e3 100644 --- a/layouts/partials/tags.html +++ b/layouts/partials/tags.html @@ -1,19 +1,25 @@
- {{range $taxonomyname, $taxonomy := .Site.Taxonomies}} - {{range $key, $value := $taxonomy }} - - - - - - {{$key}} - - {{end}} - {{end}} -
\ No newline at end of file + {{ range $taxonomy, $terms := site.Taxonomies }} + {{ range $term := $terms }} + + {{ if eq $taxonomy "tags" }} + + + + + {{ else }} + + + + + {{ end }} + {{ .Page.Title | lower }} + + {{ end }} + {{ end }} +