From 722bb79adfe7b646949b35b4d2306c93f9b7d7b6 Mon Sep 17 00:00:00 2001 From: Joseph Elliott Hand Date: Thu, 23 Jul 2026 13:29:47 -1000 Subject: Add tags to blog Signed-off-by: Joseph Elliott Hand --- content/blog/intro-to-compiling-c/index.md | 1 + hugo.toml | 10 ++++++++-- layouts/blog/page.html | 9 +++++++++ layouts/blog/section.html | 3 +++ layouts/blog_tags/term.html | 10 ++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 layouts/blog_tags/term.html diff --git a/content/blog/intro-to-compiling-c/index.md b/content/blog/intro-to-compiling-c/index.md index 56f06b5..293382e 100644 --- a/content/blog/intro-to-compiling-c/index.md +++ b/content/blog/intro-to-compiling-c/index.md @@ -1,6 +1,7 @@ +++ date = '2026-07-19T19:46:49-10:00' title = 'Intro to Compiling C' +blog_tags = ['C', 'code'] +++ This guide explains to someone very new to C how to make compiling C code as diff --git a/hugo.toml b/hugo.toml index e821679..5813d34 100644 --- a/hugo.toml +++ b/hugo.toml @@ -3,8 +3,14 @@ languageCode = 'en-us' title = 'Joseph Hand' [markup] - [markup.highlight] - style = "pygments" + [markup.highlight] + style = "pygments" + +[taxonomies] + blog_tag = "blog_tags" + +[permalinks] + blog_tags = "/blog/tags/:slug" [menus] [[menus.nav]] diff --git a/layouts/blog/page.html b/layouts/blog/page.html index 67e7901..bd051cc 100644 --- a/layouts/blog/page.html +++ b/layouts/blog/page.html @@ -1,5 +1,14 @@ {{ define "main" }}

{{ .Title }}

{{ .Date.Format "Jan 2, 2006" }} – {{ .WordCount }} words, ~{{ .ReadingTime }} minutes

+{{- if isset .Params "blog_tags" -}} +{{- $tagsLen := len .Params.blog_tags -}} +{{- if gt $tagsLen 0 -}} +

+{{- range $i, $v := .Params.blog_tags -}} +{{- if $i }},{{ end }} {{ $v }} +{{- end -}}

+{{- end -}} +{{- end -}} {{ .Content }} {{ end }} diff --git a/layouts/blog/section.html b/layouts/blog/section.html index 4bbfd38..d153a19 100644 --- a/layouts/blog/section.html +++ b/layouts/blog/section.html @@ -1,5 +1,8 @@ {{ define "main" }}

{{ .Title }}

+

Explore tags: +{{- $tagsLen := len .Site.Taxonomies.blog_tags }} +{{ range $i, $term := .Site.Taxonomies.blog_tags.ByCount }}{{ if $i }},{{ end }} {{ $term.Name }} ({{ $term.Count }}){{ end }}

{{ .Content }}