Meta tags for blog tags

SOLVE
Highlighted
Occasional Contributor

Hi!

 

Hope you are doing well.

 

How do we override the meta tags for the blog TAG page?

We wanted a custom meta title and description for each tag page. 

 


Hope you could help. 

 

Thank you!

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Solution
Advisor | Elite Partner

@jjimeno HubL doesn't work in .js files is why it doesn't work there. You would need to add it into the HTML. The javascript will completely rewrite the tags. What I meant about "adding a meta tag directly into the template" was just adding the meta tag instead of writing it with javascript (<meta name="description">Your meta here</meta>) -- that's the solution that could cause discrepancies, not the javascript workaround.

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

View solution in original post

5 Replies 5
Highlighted
Community Manager

Hi @jjimeno 

I am, indeed, doing well 🙂

First of all how are you building your blog pages?  Are you using the drag and drop or are you coding (either in Design Manager or locally)? It will make a difference in how you solve this one

@jonchim , @John , @amwilie , how would you all approach this?

 

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
Reply
0 Upvotes
Highlighted
Esteemed Contributor | Platinum Partner

A workaround would be to use hubdb.

  1. create a table titled "blog meta"
  2. use the name column that matches the tag slug.
  3. create a meta_description column and enter your custom meta there

From there, you could put logic in your blog template to pull in your custom meta from your custom "blog meta" table if it is a tag page.



Will you please help the community and give me some street cred by marking my answer as a solution if helped you? I'm fixing to buy a minivan and my cool points are running low.

Curious cats can find me at Ascend Inbound Marketing

Highlighted
Advisor | Elite Partner

@jjimeno Hubspot currently does not have a built in way to change these. Not sure when it'll become available as there's been an Ideas post for it since 2018 which I would recommend upvoting. You can however change them using javascript.

 

 

{% if topic %}
  <script>
    document.title = "Change Title | {{ topic|title }}";
    document.querySelector('meta[name="description"]').setAttribute("content", "Change Topic Description of {{ topic|title }}");
  </script>
{% endif %}

 

 

Just add to the "Additional markup before </body>" field in your drag and drop template or somewhere before the </body> tag in your code if you're using a coded template.

You could also try just adding a meta tag directly into the template but it's possible the Hubspot generated one will be given priority over the new one and not work.

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

Highlighted
Occasional Contributor

Hi guys!

 

thank you for the reply. 

 

@dennisedson we are building our blog pages locally. @John, yes this how we store the metadata for the blog tags. 🙂 

@amwilie I have tried changing them using javascript but added the codes in the .js file. I will try your suggestion which is to add it to the template, however, there are already existing meta tags for that page as you have mentioned and it might not work. But ill give it a try and get back to you. 

 

Thank you!

Reply
0 Upvotes
Highlighted
Solution
Advisor | Elite Partner

@jjimeno HubL doesn't work in .js files is why it doesn't work there. You would need to add it into the HTML. The javascript will completely rewrite the tags. What I meant about "adding a meta tag directly into the template" was just adding the meta tag instead of writing it with javascript (<meta name="description">Your meta here</meta>) -- that's the solution that could cause discrepancies, not the javascript workaround.

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

View solution in original post