CMS Development

Nagashree
Member

Overwrite/replace the auto-generated Open Graph Tags (OG Tags) on HubSpot

SOLVE

Hello Everyone,

 
I would like to change the image and title of our social media post-sharing for a few web pages/blogs. Is there a way to overwrite or replace HubSpot's current auto-generated open graph tags (OG tags)?
Could you please let me know if you have any other alternative ideas to implement?
 
Thank you in advance!
0 Upvotes
1 Accepted solution
Anton
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Overwrite/replace the auto-generated Open Graph Tags (OG Tags) on HubSpot

SOLVE

Hi @Nagashree

 

short answer: yes there is a way.

 

But for best solution you should have a developer to your side. 

 

My personal approach is always:

- open the base layout of your theme. (most likely base.html)

- add a new "building block" like this after the {{standard_header_includes}}-tag to the <head>-tag

 

{% block head_tag %}
{% endblock head_tag %}

 

- open your desired template you'd like to change the OG infos of and write it like this

 

{% block head_tag%}
<meta property="og:title" content="{{content.name}}" />
<meta property="og:description" content="{{content.post_body|striptags|truncate(160,'...', true)" />
<meta property="og:image" content="{{content.featured_image}}" />
{% endblock head_tag %}

 

 

This Hubl codes will get all the informations of the blog posts or pages. If you'd like to change them manually you should consider a custom module for this. 

 

If you can wait - I can create such module for my freebieFriday this week. Then you could download it from my github repo

 

 

best, 

Anton

Anton Bujanowski Signature

View solution in original post

2 Replies 2
Anton
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Overwrite/replace the auto-generated Open Graph Tags (OG Tags) on HubSpot

SOLVE

Hi @Nagashree

 

short answer: yes there is a way.

 

But for best solution you should have a developer to your side. 

 

My personal approach is always:

- open the base layout of your theme. (most likely base.html)

- add a new "building block" like this after the {{standard_header_includes}}-tag to the <head>-tag

 

{% block head_tag %}
{% endblock head_tag %}

 

- open your desired template you'd like to change the OG infos of and write it like this

 

{% block head_tag%}
<meta property="og:title" content="{{content.name}}" />
<meta property="og:description" content="{{content.post_body|striptags|truncate(160,'...', true)" />
<meta property="og:image" content="{{content.featured_image}}" />
{% endblock head_tag %}

 

 

This Hubl codes will get all the informations of the blog posts or pages. If you'd like to change them manually you should consider a custom module for this. 

 

If you can wait - I can create such module for my freebieFriday this week. Then you could download it from my github repo

 

 

best, 

Anton

Anton Bujanowski Signature
Jaycee_Lewis
Community Manager
Community Manager

Overwrite/replace the auto-generated Open Graph Tags (OG Tags) on HubSpot

SOLVE

Thank you, @Anton 🙌

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes