Is this possible with hugo ? multiple tags selections and display the ones which be selected?

before making a request to a hugo theme, wonder if this is even possible with hugo ?
For example, a site has tags as : 2021, 2022, 2023, and Linux, Window and Mac and ubuntu, arch, window10, window11, macIntel, macArm

now for the UX, would like to provide feature for the users can quick select any combination of multiple tags;
like 2021,2022 Linux and ubuntu, where only posts with all 4 tags with displays and
2021, Linux, and arch where only posts with all 3 tags with displays and
2021 and 2022 and arch where only posts with all 2 tags with displays and
window where only posts with all 1 tags with displays.

Maybe we can/( need to) create all possible combined tags first , where combing multiple tags of #2021 and #2022 with the rest and create each possible combination tags as #2022-2021 in the back, so when visitors choose multiple tags as #2022 and #2021 and just return one #2021-2022 tag
and all possible comminations:

2021-window, 2021-macIntel, 2021-macArm, 2021-linux
2021-2022-window, 2021-2022-macIntel, 2021–2022-macArm, 2021-2022-linux

(hopeful get the point across)

Thank you.

A dynamic, faceted filter is possible with JavaScript, but this is not a trivial exercise, and not within this scope of this support forum.

You could manually create a static list page for each combination, but this doesn’t scale well (e.g., 3 years * 3 operating systems * 2 architectures = 18 list templates).

If you really need to do this, I’d take a hard look at using a dynamic CMS.

3 Likes

I like the idea of multiple selection for tags, categories, etc. and would definitely look into it if I had time.

However, from the examples you gave, I wonder whether you actually need this feature.

  • If someone was looking for posts about Arch (assuming this is Arch Linux), why would they need to select the Linux tag as well?
  • Similarly, if someone was looking for posts about a specific version of Windows or Mac, wouldn’t the more specific tags (window10, window11, macIntel, macArm) meet their needs?

I’m asking these questions because you gave the example of selecting Linux and Ubuntu tags or Linux and Arch tags. But of course, you may have something else in mind (e.g. selecting posts that have both the window10 and window11 tags, and not just one or the other).

As for 2021 and 2022 tags, I wonder whether you could do this by grouping posts by year on tags pages (by relying on publishing dates, not on the 2012 and 2022 tags).
I found an example but haven’t tried it: Divide post list by year in Hugo · DigitalNotions
What do you think?

It looks like Filter content by tags, sections, etc using JS. I’m using it in a site not yet published.

I’m also using this solution, however I notice a bug when you add another tag. It takes several clicks to update the list and does not narrow the list to posts that have both tags associated to them, it shows all posts for both tags. Expands the list instead of narrowing. Is it the same for you?

See the page satdh. I made it by cloning the link I gave you and editing it one piece at a time

2 Likes

Hello @CesareS is it possible to learn how to do that ? Do you write a blog about it ? Thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.