I would like to create custom layouts for certain tag archive pages. in the listing template, is it possible to write a conditional statement that says
if post is tagged with {do this} else {do this}
similarly, on the post template, is it possible to do something if it has a particular tag?
In theory it should be very doable. It seems like first do a for loop to go through each post then an if statement for tag="My Topic". Something like:
{% set posts = blog_recent_posts('default', 4) %} {% for post in posts %} <!-- loop through posts in custom all posts variable --> {% if post.topic =="My Topic" %}
May 15, 20182:58 AM - edited May 15, 20182:59 AM
HubSpot Employee
Conditionals on blog tags
@jonlcrow yup your thought process is right on point here. Here is some code from a sample where I did something like this in the blog listing before:
{% for content in contents %} {% for topic in content.topic_list %} {% if topic.name == "Images" %} <!-- code for posts with topic name of Images --> {% else %} <!-- default code without topic --> {% endif %} {% endfor %} {% endfor %}
For the post HTML it would be the same idea except you wouldn't need the outer for content in contents loop.
With my limited knowledge of hubl, and looking through the docs above, I'm not seeing that it is possible. Tagging a few design partners for further help. @jonlcrow@Jlamb1@JasonRosa Can you assist?
Thank you,
Ed Justen
Did my post help answer your query? Help the Community by marking it as a solution