CMS Development

jjimeno
Participant | Partenaire solutions Diamond
Participant | Partenaire solutions Diamond

Meta tags for blog tags

Résolue

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!

1 Solution acceptée
alyssamwilie
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Meta tags for blog tags

Résolue

@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.

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

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

Voir la solution dans l'envoi d'origine

5 Réponses
jjimeno
Participant | Partenaire solutions Diamond
Participant | Partenaire solutions Diamond

Meta tags for blog tags

Résolue

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. 🙂 

@alyssamwilie 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!

0 Votes
alyssamwilie
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Meta tags for blog tags

Résolue

@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.

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

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
alyssamwilie
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Meta tags for blog tags

Résolue

@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.

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

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
John
Contributeur de premier rang | Partenaire solutions Platinum
Contributeur de premier rang | Partenaire solutions Platinum

Meta tags for blog tags

Résolue

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.



I like kudos almost as much as cake – a close second.

dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Meta tags for blog tags

Résolue

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 , @alyssamwilie , how would you all approach this?

 

0 Votes