I’m new to Hugo. I’m trying to create a page that simply lists out all of the site’s tags along with a count and URL to those tags. I’d like this page to be off of the home menu. I’ve been reading through the GoHugo.io documentation and trying everything within layouts but I simply cannot get this to work for whatever reason, it just will not render. I’ve tried many times at this and apparently I’m just missing something. Would someone be willing to help me out and offer another set of eyes?
@andrewrgoss I’m not sure how your source is set up and I’m about to take off and don’t have time to check, but hope this helps.
- Make sure you have the following in your
config.toml
:
[taxonomies]
tag = "tags"
- Then in
layouts/_default/terms.html
<ul class="tags-listing">
{{ $data := .Data }}
{{ $thisURL := .URL}}
{{ range $key,$value := .Data.Terms.Alphabetical }}
<li class="site-tag">
<a href="/{{ $data.Plural }}/{{ $value.Name | urlize }}">
<h3>{{ replace $value.Name "-" " " }} ({{ $value.Count }})</h3></a>
</li>
{{ end }}
</ul>
Of course change your CSS classes to whatever you want.
1 Like
@rdwatters thank you very much, exactly the tip I needed. I’ve got it working now the way I want. Greatly appreciate your assistance here.
1 Like