Pulling Article Snippets

Occasional Contributor

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

5 Replies
Regular Advisor | Gold Partner | HubSpot Certified Trainer

@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 Smiley Very Happy


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

 

Drop by and say Hi to me on slack.

Reply
0 Upvotes
Occasional Contributor

@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.jpgBlog 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_edit.jpgBlog Post content

 

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

Reply
0 Upvotes
Occasional Contributor

@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

Regular Advisor | Gold Partner | HubSpot Certified Trainer

Awesome @swarming - Is it all working now?


If this answer helped, please, mark as solved Smiley Very Happy


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

 

Drop by and say Hi to me on slack.

Reply
0 Upvotes
Occasional Contributor

It should now work for @Emma817.

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