Display tags on a blog post

I’m a HubSpot novice developing a blog and am trying to get the tags I’ve assigned to a post to appear on the post once published. Ideally they should be clickable (i.e., go to another page listing all of the blogs using that tag). From the bit of reading I’ve done it sounds like HubL is required? Thanks!

Hi @IPars, this is possible and yes, HubL is required.

If you check Hubspot’s Blog template markup documentation, there’s a great example that does exactly what you need.

{% if content.tag_list %}
 <div class="blog-post__tags">
 {% icon name="tag" style="SOLID" %}
 {% for tag in content.tag_list %}
 <a class="blog-post__tag-link" href="{{ blog_tag_url(group.id, tag.slug) }}">{{ tag.name }}</a>{% if not loop.last %},{% endif %}
 {% endfor %}
 </div>
{% endif %}

The previous code should loop through all the tags assigned to your blog post and will display a link to the tag page.

This solution is technically correct. However hubspot documenation does not mention this object anywhere in their documentation. Hubspot says tags is the method for grabbing tags from the post on the Standard Tags docs and doesn’t list any info for tags on the HubL variables docs. The only place this is mentioned is the Blog templates docs, which contains broken links to their github repo for their boilerplate template.

@Jnix284

Thank you @EdCupaioli I’ve submitted feedback to our technical writers to address the issues with the documentation.

@EdCupaioli following up to let you know the tech writers were able to complete the following updates earlier this week that should address these concerns:

  • Updated the broken GitHub links to go to the correct places. In cases where we were linking to files that no longer exist, I linked to either the most relevant place or removed the link altogether and replaced the content.
  • Updated code samples to match whatever the latest version of the CMS boilerplate code is.
  • Added a section to the blog template doc that explains in more depth how the tag_list tag works (since that was the example they were looking for in the original Community thread).
  • Updated the blog variables reference to include tag_list (from the original thread). Basically, the content.topic_list variable we were documenting before is an older alias for tag_list so this should make the doc more up to date. I also added an alert to the top of the blog variables section there to mention the topic/tag alias
  • Updated some other HubL docs to use tag instead of topic (like the HubL tags, and some misc code block fixes

Thanks so much Albert, worked like a charm! Have a great weekend.

Hey, @IPars. Thanks for letting us know that worked :raising_hands: