# Custom Modules on Blog Index

**URL:** <https://community.hubspot.com/t/custom-modules-on-blog-index/42579>\
**Category:** CMS Development\
**Created:** [August 19, 2021, 4:59pm UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579 "2021-08-19T16:59:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rossatgrowth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rossatgrowth/32/106227_2.png) [@rossatgrowth](https://community.hubspot.com/u/rossatgrowth)\
**Post date:** [August 19, 2021, 4:59pm UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579/1 "2021-08-19T16:59:58Z")

</div>

Hello all,

We’re building out a blog listing and post template for a client. In our mockup, the top section of the index contained a “featured post” that the client can edit the image and content for depending on which post they want to be pinned. However, there doesn’t seem to be an option to edit the content on the blog index page.

Is this possible? If not, is it possible to display the first (latest) post content in this section, and in the actual index section start at the 2nd most recent post (I imagine this would use a HubL loop/filter of some sort) ?

Thanks!

-Ross

---

<div class="post-metadata">

**Author:** ![albertsg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/albertsg/32/99473_2.png) [@albertsg](https://community.hubspot.com/u/albertsg)\
**Post date:** [August 19, 2021, 10:41pm UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579/2 "2021-08-19T22:41:25Z")

</div>

Hi @rossatgrowth, yes it is possible!  
I believe you have several ways to solve it, here are some ideas:

- Use [blog\_recent\_posts](https://developers.hubspot.com/docs/cms/hubl/functions#blog-recent-posts) function to get the latests articles (they are sorted by most recent first).
- Use a tag (for example #pinned) and [blog\_recent\_tag\_posts](https://developers.hubspot.com/docs/cms/hubl/functions#blog-recent-tag-posts) to get the latest article with this tag.
- Create a custom module in your blog posts that allows the “pinned/featured” option, so in your listing code you can show the latest post with this option enabled (boolean).

Hope you find this information useful!

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 20, 2021, 7:45am UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579/3 "2021-08-20T07:45:37Z")

</div>

@rossatgrowth the suggestion of @albertsg is correct.

You can only edit the content of modules through the template itself. You could setup an HubDB and add the right fields there for this specific element.

**So lets assume you want the newest post, your code could looke something like this:**

```lia-code-sample
{% if current_page_num == 1 %} // If you only want to show the newest post on the first page of your blog (and have pagination)
 <div class="featured-post-container">
 {% set featured_post = contents[0] %}
 // Add HTML using the contents of featured_post
 </div>
{% endif %}

// Start the default loop here
<div class="posts-container">
 {% for post in contents %}
 {% if not loop.first %}
 // Add HTML using the contents of post
 {% endif %}
 {% endfor %}
</div>

```

**If you want to show a featured post based on a tag, you could do something like this:**

```lia-code-sample
{% if current_page_num == 1 %} // If you only want to show the newest post on the first page of your blog (and have pagination)
 <div class="featured-post-container">
 {% set featured_post = blog_recent_tag_posts('default', 'featured', 1 )[0] %}
 // Add HTML using the contents of featured_post
 </div>
{% endif %}

// Start the default loop here
<div class="posts-container">
 {% for post in contents %}
 // Add HTML using the contents of post
 {% endfor %}
</div>

```

Where the second argument of **blog\_recent\_tag\_posts** should be the name of the tag for your featured post.

---

<div class="post-metadata">

**Author:** ![rossatgrowth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rossatgrowth/32/106227_2.png) [@rossatgrowth](https://community.hubspot.com/u/rossatgrowth)\
**Post date:** [August 20, 2021, 2:31pm UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579/4 "2021-08-20T14:31:51Z")

</div>

Thanks @albertsg and @Teun,

Both answers were extremely helpful! I marked each as a solution and thanks @Teun for explaining in further detail with examples (best way to learn!).

The tag approach definitely works best for this particular instance, but out of curiosity say I wanted to feature the most recent post at the top of the page and list the rest of the posts in a section below. How would I accomplish the second section by skipping over the first iteration of the for loop so the most recent post is not repeated in both sections?

Thanks again,

Ross

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 20, 2021, 3:44pm UTC](https://community.hubspot.com/t/custom-modules-on-blog-index/42579/5 "2021-08-20T15:44:32Z")

</div>

@rossatgrowth  
The first code snippet in my comment does just that! The if statement using ‘if not loop.first’ lets you skip the first iteration.
