For the “PostgreSQL Person of the Week” interviews I’m using Hugo as static blogging engine. Part of every interview is the list of tags, which links this interview to other similar interviews. However until recently no one really knew if a tag is popular or just used in this interview. I wanted to change this, and add the tag count behind every tag.
The way I use Hugo I have the previews also online, and I don’t want to count any interviews which are not published (still drafted) when counting entries for a tag.
Tags in Hugo are taxonomies, which is a user-defined grouping of content.
The original code in the overview page (
themes/pglive/layouts/_default/single.html) looked like this:
This loops over all tags in the current posting, and generates one link per entry.
In the new version I need to apply some filters before I can count the entries. First I need to exclude all pages which are still in review (drafted interviews), and second I only want posts, not news entries. Then I can count all interviews which include the current tag.