Filter tags by category

Hi,

is there a simple way on getting tags.byCount or similar based on category basis?

I have couple off different categories like “jobs”, “news”, “events” and pages in these may have multiple tags.

Now I want to build a tag cloud eg only for the most top 20 used tags in the category jobs. Same for news and events.

Is it possible to filter tags by category?

Thanks for help, Kersten

I’ll give you a starting place for this, though I think a little more specifics might be needed to help you further:

Hugo has a really cool “Set in Map” feature that you can tap into:

I’ve used them here: https://github.com/thenewdynamic-org/thenewdynamic.org/blob/master/layouts/partials/tools/filters-within-section.html

But I’m not entirely sure this is what you’re after.

I should add that this method is not too efficient. If you have a large site or a lot of tags, you’ll feel it in your build times.

1 Like