# Exclude Most Recent Blog Using HubL

**URL:** <https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342>\
**Category:** CMS Development\
**Created:** [February 2, 2023, 2:41pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342 "2023-02-02T14:41:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RGrimsley](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@RGrimsley](https://community.hubspot.com/u/RGrimsley)\
**Post date:** [February 2, 2023, 2:41pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342/1 "2023-02-02T14:41:47Z")

</div>

Hey, folks!

I’m very new to the HubL world, so please forgive me if this is a very simple fix! I’m trying to create two containers to house our most recent blogs. One will be full-width and host the most recent blog, while the following will be three columns and host the previous 3 blogs. I’m having trouble creating an HTML + HubL function to ensure the most recent blog will be excluded from the three-column container. Can someone please help if they know how to fix this?

Here’s the code I’m currently using:

\<div class=“listing-full-wrap”\>  
\<div class=“content-wrapper”\>  
\<div class=“row”\>  
\<section class=“blog-index-wrap”\>  
{% set rec\_posts = blog\_recent\_posts(module.select\_blog, 1) %}  
{% for rec\_post in rec\_posts %}  
\<div class=“post-items”\>

{% if rec\_post.featured\_image %}  
\<div class=“summary-thumbnail-outer-container”\>  
\<a href=“{{ rec\_post.absolute\_url }}” class=“gallery-image-container”\>  
\<div class=“summary-thumbnail img-wrapper”\>  
\<img src=“{{ rec\_post.featured\_image }}” alt=“{{ rec\_post.name }}”\>  
\</div\>  
\</a\>  
\</div\>  
{% endif %}

\<div class=“summary-content gallery-meta-container”\>  
\<div class=“summary-title”\>  
\<a href=“{{ rec\_post.absolute\_url }}” class=“summary-title-link”\>{{ rec\_post.name }}\</a\>  
\</div\>  
\<div class=“summary-excerpt summary-excerpt-only”\>  
\<p\>  
{{ rec\_post.post\_list\_content|truncatehtml(300)|striptags|safe }}  
\</p\>  
\</div\>  
\<div class=“container–below-content”\>  
\<div class=“summary-metadata–primary”\>  
\<time class=“summary-metadata-item summary-metadata-item–date”\>{{ rec\_post.publish\_date\_local\_time.strftime(‘%b %d, %Y’) }}\</time\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
{% endfor %}

\</section\>  
\</div\>  
\</div\>  
\</div\>

\<div class=“listing-columns-wrap”\>  
\<div class=“content-wrapper”\>  
\<div class=“row”\>  
\<section class=“blog-index-wrap”\>  
{% set rec\_posts = blog\_recent\_posts(module.select\_blog, 3) %}  
{% for rec\_post in rec\_posts %}

\<div class=“post-items”\>  
{% if rec\_post.featured\_image %}  
\<div class=“summary-thumbnail-outer-container”\>  
\<a href=“{{ rec\_post.absolute\_url }}” class=“gallery-image-container”\>  
\<div class=“summary-thumbnail img-wrapper”\>  
\<img src=“{{ rec\_post.featured\_image }}” alt=“{{ rec\_post.name }}”\>  
\</div\>  
\</a\>  
\</div\>  
{% endif %}

\<div class=“summary-content gallery-meta-container”\>  
\<div class=“summary-title”\>  
\<a href=“{{ rec\_post.absolute\_url }}” class=“summary-title-link”\>{{ rec\_post.name }}\</a\>  
\</div\>  
\<div class=“summary-excerpt summary-excerpt-only”\>  
\<p\>  
{{ rec\_post.post\_list\_content|truncatehtml(300)|striptags|safe }}  
\</p\>  
\</div\>  
\<div class=“container–below-content”\>  
\<div class=“summary-metadata–primary”\>  
\<time class=“summary-metadata-item summary-metadata-item–date”\>{{ rec\_post.publish\_date\_local\_time.strftime(‘%b %d, %Y’) }}\</time\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
{% endfor %}

\</section\>  
\</div\>  
\</div\>  
\</div\>

---

<div class="post-metadata">

**Author:** ![Brownstephen101](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/brownstephen101/32/52735_2.png) [@Brownstephen101](https://community.hubspot.com/u/Brownstephen101)\
**Post date:** [February 2, 2023, 6:54pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342/2 "2023-02-02T18:54:42Z")

</div>

Change:  
{% set rec\_posts = blog\_recent\_posts(module.select\_blog, 3) %}  
to  
{% set rec\_posts = blog\_recent\_posts(module.select\_blog, 4) %}  
Then in the {% for %} loop, wrap .post items with {% unless loop.index == 0 %}  
This should skip your most recent blog and then loop through to the next 3

---

<div class="post-metadata">

**Author:** ![RGrimsley](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@RGrimsley](https://community.hubspot.com/u/RGrimsley)\
**Post date:** [February 2, 2023, 7:19pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342/3 "2023-02-02T19:19:04Z")

</div>

Thank you so much for this edit! I made the change to this, but it’s still rendering my most recent blog:

\<div class=“listing-columns-wrap”\>  
\<div class=“content-wrapper”\>  
\<div class=“row”\>  
\<section class=“blog-index-wrap”\>  
{% set rec\_posts = blog\_recent\_posts(module.select\_blog,

**4**

) %}  
{% for rec\_post in rec\_posts %}

**{% unless loop.index == 0 %}**

\<div class=“post-items”\>  
{% if rec\_post.featured\_image %}  
\<div class=“summary-thumbnail-outer-container”\>  
\<a href=“{{ rec\_post.absolute\_url }}” class=“gallery-image-container”\>  
\<div class=“summary-thumbnail img-wrapper”\>  
\<img src=“{{ rec\_post.featured\_image }}” alt=“{{ rec\_post.name }}”\>  
\</div\>  
\</a\>  
\</div\>  
{% endif %}

**{% endunless %}**

Did I put this in the right place?

---

<div class="post-metadata">

**Author:** ![Brownstephen101](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/brownstephen101/32/52735_2.png) [@Brownstephen101](https://community.hubspot.com/u/Brownstephen101)\
**Post date:** [February 2, 2023, 8:28pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342/4 "2023-02-02T20:28:21Z")

</div>

Sorry, I forgot that loop.index actually starts at 1. So just update it to be {% unless loop.index == 1 %} and it should work.

---

<div class="post-metadata">

**Author:** ![RGrimsley](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@RGrimsley](https://community.hubspot.com/u/RGrimsley)\
**Post date:** [February 2, 2023, 8:53pm UTC](https://community.hubspot.com/t/exclude-most-recent-blog-using-hubl/74342/5 "2023-02-02T20:53:08Z")

</div>

THAT WORKED!! Thank you so much!!!
