I have a blog listing and there is right sidebar as a topics once i click on perticular tags in blog post in sidebar listing links, there sholud be link name as a page title. How to achive it using hubspot?
Hi there!
You can use HubL’s blog_topics function to retrieve the topics and then loop through each one, like this:
{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>
When you click through to the topic page, you can use the following to retrieve the topic name from the URL and print it out as a title:
{% set topic_name = topic|replace('-', ' ')|title %}
<h1>{{ topic_name }}</h1>
I hope that helps!
Stephanie O’Gay Garcia
HubSpot Design / Development
If this helped, please mark it as the solution to your question, thanks!
@Stephanie-OG is this still the only way to achieve this functionality? We have more complex topic names that don’t fit a standard character replace - eg camel case, hyphens that form part of the tag name and need to stay, etc.
@Craig - The tag/topic page title is going to be something like “Your Blog Name | Tag Name”, so you can split from the “|” to get the tag/topic name. Check out the documentation here:
{% if tag %}
<h3>Posts about {{ page_meta.html_title|split(' | ')|last }}</h3>
{% endif %}
Stephanie O’Gay Garcia
@Stephanie-OG great idea - thanks, all working.
