# Blog pagination with loop

**URL:** <https://community.hubspot.com/t/blog-pagination-with-loop/6047>\
**Category:** CMS Development\
**Created:** [January 2, 2018, 5:56pm UTC](https://community.hubspot.com/t/blog-pagination-with-loop/6047 "2018-01-02T17:56:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulpf](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paulpf/32/26012_2.png) [@paulpf](https://community.hubspot.com/u/paulpf)\
**Post date:** [January 2, 2018, 5:56pm UTC](https://community.hubspot.com/t/blog-pagination-with-loop/6047/1 "2018-01-02T17:56:39Z")

</div>

Hi,  
I’ve come across several posts regarding pagination but I can’t fix my problem.  
I’m trying to run a loop for every pages I might have based on my contents and trying to :  
display the current one, display the next one, and add a link for the other pages.  
It is supposed to look like this (considering we are on the first page) but all I have so far is : 0 0 \>

 ![Screen Shot 2018-01-02 at 18.52.39.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/6/56dbf50a9bd5524f206d1cb1f5ab79b63237a0a9.png)

This is my code so far :

```auto
 <div class="p-n flex-row a-c">
 <a href="{{ content.post_slug }}" class="p-n c">
 <span>{{ current_page_num }}</span>
 </a>
 <a href="{{ content.next_post_slug }}" class="p-n">
 <span>{{ next_page_num }}</span>
 </a>
 <a href="{{ content.next_post_slug }}">
 <img src="/.../blue-arrow.svg" alt="blue arrow">
 </a>
 </div>

```

When I’m trying to run a foor loop on it I can’t display what I want.  
If anyone has an answer it would be greatly appreciated !  
Best,

---

<div class="post-metadata">

**Author:** ![roisinkirby](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@roisinkirby](https://community.hubspot.com/u/roisinkirby)\
**Post date:** [February 2, 2018, 10:46am UTC](https://community.hubspot.com/t/blog-pagination-with-loop/6047/2 "2018-02-02T10:46:10Z")

</div>

Hello @paulpf are you still experiencing this roadblock? If so let me know and I’ll connect you with a design expert.

---

<div class="post-metadata">

**Author:** ![paulpf](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paulpf/32/26012_2.png) [@paulpf](https://community.hubspot.com/u/paulpf)\
**Post date:** [February 2, 2018, 3:50pm UTC](https://community.hubspot.com/t/blog-pagination-with-loop/6047/3 "2018-02-02T15:50:01Z")

</div>

Hi,  
No I’ve finally fixed it. All good thanks,  
Here is the solution I found if anyone else need it

```auto
<div class="pagination wrapper flex-row space-between">
 {% if not simple_list_page %}
 <div class="pages-navigation flex-row align-center">
 {% if current_page_num > 1 %}
 {% set previous = current_page_num - 1 %}
 <a rel="nofollow" href="{{ blog_page_link(previous) }}"> 
 <img class="blue-arrow-reverse" src="" alt="blue arrow">
 </a>
 {% endif %} {% if current_page_num %}
 <a href="{{ content.post_slug }}" class="page-number current">
 <span>{{ current_page_num }}</span>
 </a>
 {% endif %} {% if next_page_num %}
 <a href="{{ blog_page_link(next_page_num) }}" class="page-number">
 <span>{{next_page_num }}</span>
 </a>
 <a rel="nofollow" href="{{ blog_page_link(next_page_num) }}">
 <img src="" alt="blue arrow">
 </a>
 {% endif %}
 </div>
 {% endif %}

```

Best.  
Paul
