Displaying Only Unique Topics in For Loop

Contributor | Platinum Partner

I'm using a for loop to gather topics from all blog posts and populate those topics in a select element. I'm currently seeing duplicates due to the same topics across multiple blog posts. Here is my code:

<!-- Services Filter -->
<select class="select-filter" data-filter-group="services">
  <option value="*">Services</option>
  {% for content in contents %}
  {% for topic in content.topic_list %}
  <option value=".filter-{{ topic.name|lower|replace(' ','-') }}">{{ topic.name }}</option>
  {% endfor %}
  {% endfor %}

I see that there is a HubL filter for unique. I tried a few things but didn't have any luck. How would I incorporate the unique filter so there are no duplicate topics in my select element?

1 Reply 1
HubSpot Product Team

Hey @tstrack could you share a link to the page(s) you are working on? @dessery is this something you have acheived before?