Tags minimal example

I want to get into taxonomies, but I must say I have stumbled with the documentation.

image

  • layouts/tags/list.html I assumed listed/rendered /tags/index.html but it’s not! It’s actually /tags/$tagname/index.html … aka the term!
  • layouts/tags/terms.html I assumed was /tags/$tagname/index.html as I assumed $tagname was a term, but it’s not! It’s actually /tags/index.html… the listing of taxonomy! i.e. layouts/tags/terms.html renders /tags/!

The example template here: https://gohugo.io/templates/taxonomy-templates/#order-alphabetically-example … what is it for? list.html or terms.html? It’s not clear. :confused:

I think I have a minimal tag site produced with this shell:

hugo new site ${1:-"testing"}
cd ${1:-"testing"}
mkdir layouts/_default layouts/tags
echo -e "<h1>Hello from layouts - single</h1>\n{{ .Content }}" > layouts/_default/single.html

cat << EOL > layouts/tags/terms.html
<h1>In tags/terms!!!</h1>
<ul>
{{ range .Data.Terms.Alphabetical }}
<!-- RelPermalink does not work in this context -->
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
{{ end }}
</ul>
EOL

cat << EOL > layouts/tags/list.html
<h1>In tags/list!!!</h1>

{{ range .Pages }}
<li>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</li>
{{ end }}

EOL

cat << EOL > content/foo.md
---
Title: Mr Foo
tags:
- foo
---

Hello from **Foo**
EOL

cat << EOL > content/bar.md
---
Title: Mr Bar
tags:
- bar
---

Hello from **Bar**
EOL

cat << EOL > content/curveball.md
---
Title: Curve ball
tags:
- bar
---

Hello from **Curveball**
EOL

hugo --disableKinds=RSS,sitemap

Could it be improved? Please let me know!

layouts/tags/section.html is rendering /tags/index.html because that is a section page.

I don’t understand your “shell”, that’s too abstract for my simple mind, hehe, but maybe the info above helps you achieve what you are going for?

Sorry this is quite confusing. layouts/tags/section.html does nothing for me in my testing!