byrdjb
July 31, 2019, 1:23pm
#1
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!
ju52
July 31, 2019, 1:44pm
#2
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
byrdjb
July 31, 2019, 1:56pm
#3
Please forgive my ignorance, but do you happen to know to what file I would append this code?
ju52
July 31, 2019, 7:31pm
#4
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
1 Like
ju52
July 31, 2019, 8:16pm
#5
{{ range $name, $taxonomy := first10 site.Taxonomies.tags.ByCount }}
.ByCount gives you the highest first
1 Like
byrdjb
August 1, 2019, 12:29am
#6
Thank you! I found that I had to add a space between first & 10, and then it worked exactly as I had hoped.