Topic page topic name not outputing.



from the documentation: "{{ topic }} - the topic variable can be used to render markup for a topic listing. It also contains the properties: and topic.slug." But it doesnt seem to be the case. I'm getting the {{topic}} variable which is the slug, but other variables, like {{ }}, i can't get. Is this an issue with hubspot or am i misunderstanding something? The page im trying to output it at is a topic page. Example and i would like to get the name of the current topic im in so "Cars dogs" or whatever you named it. 

2 Replies 2
HubSpot Employee

Hey @Armandas if you're trying to get the topic name to display on the topic page you'll have to use a bit of a workaround which is noted here ( So you'd want to use an {% if topic %} statement on the listing page. In between the if and the endif is where you'd put your topic page specific content. If you wanted to pull the name of the topic page you'd want to use: 


{{ page_meta.html_title|replace('Your Blog Title | ', '') }}


You'd then want to replace the "Your Blog Title" in that with your blog's HTML title. Basically on a topic page, the HTML title of the page is "Your Blog Title | Topic Name". The "| Topic Name" part is generated automatically. The solution above is basically a workaround that removes the first part of the Title and leaves you with the topic name. You can also set that value as a variable and use it multiple times within the {% if topic %} statement if that is easier. For example: 


{% if topic %} 

{% set topicName = page_meta.html_title|replace('Your Blog Title | ', '') %} 

<h2>{{ topicName }}</h2>

<p>On the {{ topicName }} page we talk about {{ topicName}}.</p>

{% endif %}


Hi Jason,


It seems you have conflicting HubL documentation on this. The HubL variable reference does state that the topic is a type dict variable, containing attributes name and slug:


So maybe correct that one, if the topic is just a string containing the topic slug?