CMS Development

JodieMul
Membre

Limiting the line length on a Hubspot Blog post

I would like to limit the line length to make our blogs easier to read. How can i do this? Is there a better way of doing it than using horizzontal spacers?

 

Also, I want to set a max size for our blog featured image so that I don't have to resize them each time, especially as we will be migrating over 100 posts. (We have tried the migration tool and it just didn't work)

 

TIA

0 Votes
3 Réponses
lscanlan
Ancien salarié HubSpot
Ancien salarié HubSpot

Limiting the line length on a Hubspot Blog post

Hi @JodieMul,

 

For limiting the content on the blog posts, it depends where you're trying to do that. From the listing page, wherever you're pulling in the content for each blog post, you can add the |truncatehtml filter, which is documented here: https://designers.hubspot.com/docs/hubl/hubl-supported-filters#truncatehtml. That will limit the number of characters for each blog post summary. If you have any questions about how to implement it, feel free to point me to your blog template and I can take a look.

 

HubL also has a resize_image_url() function, documented here: https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#resize-image-url. If that's not what you're looking for though, I'm happy to look at a page to see what's going on with and what we can optimize.

Leland Scanlan

HubSpot Developer Support
0 Votes
JodieMul
Membre

Limiting the line length on a Hubspot Blog post

Thanks for the reply. This was more on the actual blog post itself rather than the listings page. 

 

https://app.hubspot.com/design-manager/5712008/templates/10812804697 that is the template I have been working on.

0 Votes
lscanlan
Ancien salarié HubSpot
Ancien salarié HubSpot

Limiting the line length on a Hubspot Blog post

Hi @JodieMul,

 

So if it's the blog post body that you want to truncate, you could still use that |truncatehtml filter: https://designers.hubspot.com/docs/hubl/hubl-supported-filters#truncatehtml, but just from within the blog post template of the blog content module: https://app.hubspot.com/design-manager/5712008/templates/10812804697#module=149799020215188. You have a token {{ content.post_body }} that's taking the value of the blog post body (which is the text that's entered into the module in the editor), and then printing that value into the HTML. But you could apply a filter like {{ content.post_body|truncatehtml(250, '...', false) }} . It's typically used on the listing page because the truncation symbol implies that there's more content. But if you're concerned with your blog authors writing too much content, this could be one solution.

Leland Scanlan

HubSpot Developer Support
0 Votes