Difficulty Level: Intermediate. This post assumes a solid understanding of HubSpot tools and some technical knowledge. Instructions are detailed and can be applied as they appear on the post.
Last Updated: October 8, 2019
When you click into a tag or topic (both words are used interchangeably) in your HubSpot blog, it'll take you to the "topic" page on which you might want to add a page title that shows the tag.
In a HubSpot blog template, the topic page is usually the same as your listings page but you can modify the header by using the if topic statement, like this:
{% raw %}{% if topic %}
{# Insert your code here #}
{% end if %}
Currently there is no straghtforward way to print out the tag of the page you're on (something like a "tag" variable), so what you will usually do is get the page's HTML title (page_meta.html_title
) which is a combination of the blog title you've set in your blog settings, a pipe symbol (|) and the tag name, something like:
My Super Awesome Blog | My Topic
And then remove everything before the pipe symbol. So in the case above, your code will look something like this:
{% if topic %}
Blog Topic: {{ page_meta.html_title|replace('My Super Awesome Blog | ', '') }}
{% end if %}
Which will print out:
Blog Topic: My Topic
Written by: Stephanie O'Gay Garcia Last Updated: October 8, 2019I'd appreciate if you could take a moment to let me know how I can improve this article.
Hi! 👋 I'm a freelance HubSpot Website Developer based in Toronto (Canada). Give me a shout if you have questions about this post or there's anything I can help you with.
HubSpot is a full suite of Marketing, Sales and Services tools. Learn more here.
Note: as a HubSpot affiliate I will earn commission if you decide HubSpot's the right software for you! :)