Adding Additional Code Snippets to Blog template

Blog templates do not allow us to add the Additional Code Snippets to each blog individually, only at the template level which defeats the purpose of the meta tags (title, description, etc).

I need to add meta tags specific to each blog under the HEAD HTML section so they work with my rich pins in pinterest.

For some reason this feature is not inlcuded in the blog pages as they do in regular web pages (cms).

Both are web pages and should be able to have the ability to add additional code snippets, in my opinion. Not sure why they are even different within hubspot. Other CMS allow you to do it the way I am describing. Which helps with search engine optimization.

Hi @DMI,

You can accomplish this using a custom module inside of your blog template. Below are some steps to make this happen:

1. Create a Custom Module

In your design manager, you can create a custom module with a text field added. You’ll also want to enable the repeater options for that field. Then copy the snippet value and paste it into the area. You’ll end up with something like this:
(note: I remove the extra stuff added to the module field and just placed the {{item}} tag by itself)


code from module with repeater enabled on a text field

2. Copy the Template Usage Snippet to add to your blog template

Inside of the custom module, you’ll want to copy your template usage snippet. It should look something like this:


Sample of what the usage snippet looks like

3. Add this to your blog templates “Additional <head> Markup” area

You’ll want to add this to the “additional <head> markup” area in your template. With this, we are going to use two things:

  1. Adding a {% unless is_listing_view %} statement: This will let the module only show on the post pages and not load on the blog listing page.
  2. Adding “no_wrapper=True” to the module snippet: This will stop the system from adding wrapping HTML around the content.

You’ll end up with something similar to this in the Additional <head> Markup area (note: your snippet will be different but the placement of the no_wrapper is what you want to make sure you have):

{% unless is_listing_view %}
 <!-- Additional Meta Tags -->
 {% module "module_15694198154146" path="/Additional Meta", label="Additional Meta" no_wrapper=True %}
{% endunless %}

4. Add your meta through the post editor.

You should now be able to see your module in the post editor under the “Edit Modules” area


your edit modules area

Simply add in your meta information (one per repeating field) and publish your post. You should now be able to see the meta appear in the header of your blog posts. Below are two screenshots showing the meta added and then from the source view showing them added:


Our Meta Properties added to our module


Source view showing fields on post

Let me know if you have any questions :slightly_smiling_face:

-AJ

Hi all,

We are currently in the process of adding a new field that will let you specify custom HTML content in the <head> section of individual blog posts. For updates about the development of this functionality, I recommend following this Ideas post:

https://community.hubspot.com/t5/HubSpot-Ideas/Edit-Blog-Post-Head-Data-Individually/idi-p/12092

Best,

Lukas

Empty