Show All Tags For a Post as a List
When showing your blog post, either as a single page or within a blog post list it can be nice to show the tags associated with that post (we do here on MakeWithHugo!). This is going to be a quick post (hopefully) showing you how to add your tags as a list and each linked up.
You can add this code to either your
single.html layout file or inside the loop in
This code works by looping our your posts tags (using
range) then making a link for each. When making the url we pass the tag name through
urlize first incase there are spaces or non-url compatible characters.
For this to work, you’ll need to define your tags on the post like this:
Which in HTML will output something like this (I’ve changed the indentation a bit):
Hopefully you found this useful. Let us know how you get on in the comments below.
Site illustrations (of Hugo the rabbit) drawn by Carina Roberts.