# Filter product collection loop with featured products and custom frontmatter

**URL:** <https://talk.jekyllrb.com/t/filter-product-collection-loop-with-featured-products-and-custom-frontmatter/5278>\
**Category:** Help\
**Created:** [November 27, 2020, 2:06am UTC](https://talk.jekyllrb.com/t/filter-product-collection-loop-with-featured-products-and-custom-frontmatter/5278 "2020-11-27T02:06:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [November 27, 2020, 1:57pm UTC](https://talk.jekyllrb.com/t/filter-product-collection-loop-with-featured-products-and-custom-frontmatter/5278/4 "2020-11-27T13:57:31Z")

</div>

As mentioned in the previous answer, the solution to avoid duplication is by using _includes_ to render every section after the featured product.  
To facilitate easier maintenance, you need to merge your `_products` collection and `products` data file into one of either type — either collection of product documents or a folder of individual data files. (Yes, `_data/products/product_a.yml`, `_data/products/product_b.yml`, etc) is perfectly valid.

* * *

Since your posts need to be rendered in the ratio of 1:4:6, make sure you have configured the site to paginate posts by 11 items.

Then use `{% assign --- %}` tag and `slice` filter to manipulate the list of posts.

```nohighlight
## Sticky Post
### {{ paginator.posts[0].title }}

## Featured Posts
{% assign featured_posts = paginator.posts | slice: 1, 4 %}
{% for post in featured_posts %}
### {{ post.title }}
{% endfor %}

## More products
{% assign rest = paginator.posts | slice: 5, 6 %}
{% for post in rest %}
### {{ post.title }}
{% endfor %}

```

_Move the forloops to includes if you don’t want duplication._

---

_[View the full topic](https://talk.jekyllrb.com/t/filter-product-collection-loop-with-featured-products-and-custom-frontmatter/5278)._
