Need help: How to get list page when click on a tag shared by different sections?


#1

For the two Sections : Jobs and Events , there are tags shared between them,

.
└── content
    ├── jobs 
    │   ├── job-1.md      #with tags: golang, big-data
    │   ├── job-2.md      #with tags: golang
    │   └── job-3.md
    └── events 
        ├── event-1.md    #with tags: golang, big-data, awsome
        └── event-2.md

when I visit job-1 and click the tag: golang, I would like to list all jobs with this tag. [ --NOT list all jobs+events tagged with golang. by DEFAULT]

How should I do this ?


Taxo Buttons
Displaying all taxonomies for a specific type of content only
#2

Depending on your theme, you’ll look up the template that is rendering your tag pages, and change the range on it to only show pages from your jobs section.


#3

I don’t think that can be done elegantly… the only way that I can think of is that you manually create templates for each section + tag combination.


#4

I was thinking they didn’t want events to show up at all, in which case they could just edit the single template to only show the jobs section. Then they’ll know if that is what they really want. :slight_smile:


#5

@maiki and @kaushalmodi thanks for your quick help.

For content organization and status of my side-project (still developed on my mac-pc locally), I could point a theme for reference so that you can understand my question clearly: https://themes.gohugo.io/minimal/, and its github repository located at https://github.com/calintat/minimal

No matter in which section POSTS or PROJECTS, when you click the Golang tag, you will get a list page as shown https://themes.gohugo.io/theme/minimal/tags/golang

what I would like to get is:
1, when I visit Post Section and click Golang tag, list all Post Section pages tagged with Golang
2, when I visit Projects Section and click Golang tag, list all Project Section pages tagged with Golang

Almost same as what I am working on, so I take this theme as a example.
Thank you all again.


#6

That can’t be done with a single taxonomy. You can use multiple taxonomies, though.


#7

You can certainly do this, but not without customization of the theme, or finding a theme that is designed to do this (though I don’t know if any exist), unless you are willing to go with Option C below. Hugo’s tags work site-wide, and most if not all existing themes stick with that.

The approach you take depends on whether you want these tags to work only per section or work both ways, site-wide and per section.

Option A: per section tags

You probably should just use separate taxonomies as @maiki suggests, but then you’d have to override the theme to list on each page the section specific taxonomy rather than the global “tags” taxonomy.

Option B: global and per section tags

  1. the global tags indexes would be generated at /tags as they normally would
  2. as @kaushalmodi suggests, you have to figure out how to, under /jobs/tags and /projects/tags, generate the same kinds of pages generated under /tags, but filtered by section. Not trivial.
  3. change the page templates so that the tags for the page link to the section specific index.

Option C: per section tags (alternate approach)

Treat each section with its own tag space as a separate Hugo site, which you would publish to a subdirectory in your webroot so that the end result would be a single site. You might have to make the right settings in Hugo for that to work (base URL? relative paths?).

I think A or C is easiest, depending.


#8

@maiki thanks for instruction.

Still cannot get your point to work it out, sorry. any example of it?

Could it be a feature request? @bep


#9

Hey, please don’t tag people, especially Bjørn like that. This is a #support thread, start a #feature topic if you have a request.

Instead of having tags, create a taxonomy called posttags. Then do the same for the other section. Now you have two separate taxonomies. They will have their own lists of content tagged golang: /posttags/golang and /projecttags/golang.


#10

Apologize for my bad action.