CMS Development

Emma817
Member

Pulling Article Snippets

SOLVE

In the blog page Hubspot created for we have three tiles at the bottom that preview other blog posts. On our Wordpress version of our blog we were able to code those tiles to pull specific snippets to appear in the tile's preview rather than just the first couple sentences of the article. Is there a way to do that on Hubspot, as well?

 

Here are the URLS for reference.

 

Our Wordpress blog: https://ideon.agency/ideas/deceptive-branding/

Our Hubspot blog: http://ideas.ideon.agency/ideas/deceptive-branding

2 Accepted solutions
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling Article Snippets

SOLVE

@Emma817 -

first, go to your blog post template (not blog listing) in the design manager. When you click on the blog post module, you will see on the right, a button to edit the module code. Paste in the following code at the top of the page.

{% text "excerpt" label="Excerpt", value="" export_to_template_context="true" %}

Next, you will go into each blog post that you would like to add an excerpt to, and you will see a new module appear called excerpt, when you click on the "box icon" in the left sidebar.

 

Add some text there for your excerpt and save.

 

Now, in your custom module that is looping through the blog posts, add a variation of this code which will find the excerpt and display it.

 

(I don't have your actual module code, so here is an example):

{% set pop_posts = blog_popular_posts('default', 5) %}
  {% for pop_post in pop_posts %}
	{% for w in pop_post.allWidgets %}
           {% if w.name == 'excerpt' %}
              {{w.body.value}}
           {% endif %}
       {% endfor %}
   {% endfor %}

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

View solution in original post

0 Upvotes
swarming
Solution
Member

Pulling Article Snippets

SOLVE

@Emma817 and @tjoyce 

I found the solution, instead of adding the code to the Blog Post template, it has to be now added to the "Additional <head> markup" section on the Blog template itself. Per Hubspot support, the feature to custom module code into the Blog Post tempalte has been deprecated. 

Following is the screenshot of where I added the code and the module started appearing on the blog create/edit page; 

 

additional-markup.jpg

View solution in original post

6 Replies 6
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling Article Snippets

SOLVE

@Emma817 -

first, go to your blog post template (not blog listing) in the design manager. When you click on the blog post module, you will see on the right, a button to edit the module code. Paste in the following code at the top of the page.

{% text "excerpt" label="Excerpt", value="" export_to_template_context="true" %}

Next, you will go into each blog post that you would like to add an excerpt to, and you will see a new module appear called excerpt, when you click on the "box icon" in the left sidebar.

 

Add some text there for your excerpt and save.

 

Now, in your custom module that is looping through the blog posts, add a variation of this code which will find the excerpt and display it.

 

(I don't have your actual module code, so here is an example):

{% set pop_posts = blog_popular_posts('default', 5) %}
  {% for pop_post in pop_posts %}
	{% for w in pop_post.allWidgets %}
           {% if w.name == 'excerpt' %}
              {{w.body.value}}
           {% endif %}
       {% endfor %}
   {% endfor %}

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

0 Upvotes
Nell
Member

Pulling Article Snippets

SOLVE

Hi @tjoyce ,

 

Thank you for sharing your solutions to the Excerpt and I'm trying your method, however, I could only reach to the first step (I can see the excerpt module in my left sidebar) and I couldn't understand how to execute the second step of the module code. 

 

Could you please explain more? Would be really appreciate for the help,

 

Many thanks,

 

Sasa

0 Upvotes
swarming
Member

Pulling Article Snippets

SOLVE

@tjoyce,

I followed your exact step (even copy pasted)  to add the custom field to the blog post. 

As shown in the following snippet, the code has been added, but when I use this tempalte and create a blog post, the module does not appear on the blog create/edit page, as shown in the second screenshot. 

Blog Template editBlog Template edit

 

The following screen only shows the blog content and there is no module for the text excerpt that was added to the blog post template.

Blog Post contentBlog Post content

 

Is there any settings that have to be updated to make the module visible on the blog create/edit page?

0 Upvotes
swarming
Solution
Member

Pulling Article Snippets

SOLVE

@Emma817 and @tjoyce 

I found the solution, instead of adding the code to the Blog Post template, it has to be now added to the "Additional <head> markup" section on the Blog template itself. Per Hubspot support, the feature to custom module code into the Blog Post tempalte has been deprecated. 

Following is the screenshot of where I added the code and the module started appearing on the blog create/edit page; 

 

additional-markup.jpg

tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling Article Snippets

SOLVE

Awesome @swarming - Is it all working now?


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

0 Upvotes
swarming
Member

Pulling Article Snippets

SOLVE

It should now work for @Emma817.

I would leave it upto @Emma817 to close this question.