Using if statements to show different content depending on blog tag

SOLVE
Highlighted
Regular Contributor | Diamond Partner

Hi,

 

I'm trying to create a blog sidebar that shows different content depending on the blog tag for that post.

 

 

Here's the kind of thing I would like to be working:

 

{% if topic.name =='HubSpot' %}
<h1>Hi I'm HubSpot topic text</h1>
{% endif %}

{% if topic.name =='Inbound' %}
<h1>Hi I'm inbound topic text</h1>
{% endif %}

This is a custom module that I'm trying to use in the blog template.

 

Thanks!

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Top Contributor | Diamond Partner

This might help:

{% if 'Featured' in content.topic_list|map('name') %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endif %}

source: https://designers.hubspot.com/docs/tutorials/how-to-check-for-a-particular-topic-on-a-blog-post

 

 

 

2 Replies 2
Highlighted
Top Contributor | Diamond Partner

This might help:

{% if 'Featured' in content.topic_list|map('name') %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endif %}

source: https://designers.hubspot.com/docs/tutorials/how-to-check-for-a-particular-topic-on-a-blog-post

 

 

 

Highlighted
Regular Contributor | Diamond Partner

That works perfectly!

 

Thank you

Reply
0 Upvotes