CMS Development

benji_thecroc
Mitwirkender/Mitwirkende | Gold Partner
Mitwirkender/Mitwirkende | Gold Partner

HubL Blog Listing page based on Tag

I need to create a template using HubL that has a paginated feed of blog posts that have a certain tag. I've seen this page - https://designers.hubspot.com/docs/hubl/blog-content-markup

 

However I want to have seperate templates for a single blog post and a listing page. Is this acheivable using HubL?

 

 

4 Antworten
Jsum
Autorität

HubL Blog Listing page based on Tag

@benji_thecroc,

 

You want to list blogs that have a certain topic, you can use a one of the available blog rss feed functions provided by Huspot and explained in the HubL docs.

{% set topic_posts = blog_recent_topic_posts('default', 'marketing-tips', 5) %}
{% for topic_post in topic_posts %}
    <div class="post-title">{{ topic_post.name }}</div>
{% endfor %}

Read the docs for info on how this works, use the same slugs in the blog markup but using the single item name for the loop (topic_post in the example ablove) instead of content since your data is coming from this new loop instead of your contents loop. 

 

separating the listing and post template? there is a conditional in the blog markup:

{% if is_listing_view %}

    {# blog listing markup #}

{% else %}

    {# post markup #}

{% endif %}

you can create a template for each, or use the drag and drop builder since the listing and post markup is still coded. you just need to take the markup for the listing page and put it in one template (or in the listing section of the drag and drop template) and do the same with the markup. if you are using separate templates them you need to go into your settings for the blog in question and choose to have a separate template for each then choose the templates you created.

benji_thecroc
Mitwirkender/Mitwirkende | Gold Partner
Mitwirkender/Mitwirkende | Gold Partner

HubL Blog Listing page based on Tag

Hi Jsum

 

Thanks for the advice. Unfortunately I don't think the recent blog posts functionality can be used in tandem with pagination on the listing page.

 

Thanks,

Benji

0 Upvotes
Jsum
Autorität

HubL Blog Listing page based on Tag

@benji_thecroc,

 

If you are just wanting to have your blog show blogs under a specific topic, that is a build in function. Each topic has it's own url, and pagination should would natively under that url. 

 

If you are wanting to show multiple lists of topic specific blogs on one page then you will have to create your own pagination.

0 Upvotes
RLawrence0
Mitglied

HubL Blog Listing page based on Tag

Related question to this thread. We have multiple links to unique tag URLs on our blog - but the code being spit out looks different whether it is the normal blog listing, or if it is a listing feed of a specific tag - any idea why this might happen? I would assume a blog listing and a listing sorted by tag would use the same template code.

0 Upvotes