Is there a way to associate a description with a specific tag? Basically, on the tag list page, I want to show the tag name and tag description.
I saw this post:
https://discourse.gohugo.io/t/add-description-to-taxonomy-tags-term/31388/7
which does it by creating a template for each tag,and adding the description to the template, but I am trying to figure out if there is a central place (config?) I could define the data so I could use a single template, and not create a new template every time I add a tag.
I could probably also use a single template, and then write code to show description based on tag, but again, I was looking for a simpler solution to maintain.
https://gohugo.io/content-management/taxonomies/#add-custom-metadata-to-a-taxonomy-or-term
content directory
content/
āāā posts/
ā āāā _index.md
ā āāā post-1.md
āāā tags/
ā āāā tag-a/
ā āāā _index.md
āāā _index.md
content/tags/tag-a/_index.md
+++
title = 'Tag A'
date = 2024-06-01T09:29:49-07:00
draft = false
+++
This is the description of Tag A.
layouts directory
layouts/
āāā _default/
āāā baseof.html
āāā home.html
āāā list.html
āāā single.html
āāā taxonomy.html
āāā term.html
layouts/_default/term.html
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ with .Content }}
{{ . }}
{{ end }}
{{ end }}
{{ end }}
1 Like
ok. Just to make sure im reading this right, I need to create a page for each tag.
If you want a description specific to a given tag, then you need to create a page for that tag.
Thank you for confirming.
system
Closed
June 3, 2024, 10:23pm
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.