Display multiple tags for multiple JSON values

I have a JSON file located in the data folder with multiple names for a website like this for a lot of friends.

“Josh”: {
“name”: “Josh”,
“Description”: “25, Male, Hard-working, likes cooking,”,
“tags”: [“Male”,“Cooking”]
“Paul”: {
“name”: “Paul”,
“Description”: “21, Male, likes to watch Stranger Things,”,
“tags”: [“Male”,“Netflix”]

For now using the index function I am able to call the description and name through shortcodes,
like so:

{{ $name := .Get “name” }}
{{ $data := .Site.Data.Male-coworkers }}
{{ (index $data .Params.name).name }} - {{ (index $data .Params.name).description }}

but how could I call these tags?

I was thinking to use the range function to list the tags and urlize them.


Are you just trying to print each one out? If so, yes, range is your friend here: Introduction to Hugo Templating | Hugo

I am not sure what you are trying to do though because you also mention

1 Like

I want to create a page where all the other names associated with one tag are listed in the page.

So if I click on Male, then it would list all the names of people who have the tag male associated with them.

That sounds like you want to use Hugo’s taxonomies feature:

But that means you’d need to make each ‘person’ its own content page (instead of being a JSON entry inside your data folder) and then define their tags in their respective front matter.

1 Like

The problem is that I have a lot of names in the JSON file so creating each person’s content page would be extremely time-consuming and that’s what I’m trying to avoid.