# Assign different classes to alternating blog posts?

**URL:** <https://community.hubspot.com/t/assign-different-classes-to-alternating-blog-posts/9687>\
**Category:** CMS Development\
**Created:** [August 1, 2018, 8:24pm UTC](https://community.hubspot.com/t/assign-different-classes-to-alternating-blog-posts/9687 "2018-08-01T20:24:27Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![lgerodiaz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lgerodiaz/32/78356_2.png) [@lgerodiaz](https://community.hubspot.com/u/lgerodiaz)\
**Post date:** [August 2, 2018, 11:20pm UTC](https://community.hubspot.com/t/assign-different-classes-to-alternating-blog-posts/9687/12 "2018-08-02T23:20:16Z")

</div>

If you want the items to be grouped inside a row, you can use this code instead

```auto
{% for content in contents %}
 {{ '<div class="row">' if loop.index % 2 != 0 }}

 <div class="post-item {% cycle 'width-one-third','width-two-thirds', 'width-two-thirds','width-one-third' %}">
 ...
 </div>

 {{ '</div>' if loop.index % 2 == 0 }}
{% endfor %}

```

---

_[View the full topic](https://community.hubspot.com/t/assign-different-classes-to-alternating-blog-posts/9687)._
