Truncating 'Popular Topics' in the Academic theme

Hugo-Academic has a widget that is a tag cloud that displays as: ‘Popular Topics.’

I like it, but I have been pretty diligent in my tagging, and I would like to display only the top 10 or 15 most frequently occurring tags, rather than every tag.

Short of deleting tags, how can I truncate the list of tags included in the tag cloud?

Thanks!

You can use

{{ range first 10 site.Taxonomies.tags.ByCount }}

ev. you should append .Reverse

{{ range first 10 site.Taxonomies.tags.ByCount.Reverse }}

or

{{ range last 10 site.Taxonomies.tags.ByCount }}

1 Like

Please forgive my ignorance, but do you happen to know to what file I would append this code?

I can only try

/hugo-academic/layouts/partials/widgets/tag_cloud.html

should be line 23

    {{ range $name, $taxonomy := site.Taxonomies.tags }}

try to change to

   {{ range $name, $taxonomy :=  last 10 site.Taxonomies.tags.ByCount }}

must fiddle with the syntax to get it running :wink:

1 Like

{{ range $name, $taxonomy := first10 site.Taxonomies.tags.ByCount }}

.ByCount gives you the highest first

1 Like

Thank you! I found that I had to add a space between first & 10, and then it worked exactly as I had hoped.:grinning: