# Pagination question: Where does index.html go?

**URL:** <https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262>\
**Category:** Help\
**Created:** [March 7, 2017, 2:46am UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262 "2017-03-07T02:46:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 7, 2017, 2:46am UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/1 "2017-03-07T02:46:45Z")

</div>

I’m running Jekyll 3.4.0.

I’m new to Jekyll and I’m trying to get pagination to work. I’ve read though [Jekyll’s pagination documentation](https://jekyllrb.com/docs/pagination/) and have installed jekyll-paginate (1.1.0) and included `jekyll-paginate` in the gems list in \_config.yml file and listed `pageinate: 5` in the same file. I am forking the Minima theme and have a `home.html` page in \_layouts that is powering the homepage (somehow). I understand that I need to create an `index.html` file in the home directory and basically include the same contents of the `home.html` file in \_layouts.

Is that correct?

I’ve tried putting `index.html` in both the \_layouts and home directories of my repo but no luck. My `index.html` file doesn’t seem to become the source file of my website (I can edit the contents of `index.html` file but the contents of my site don’t change).

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 7, 2017, 4:00pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/2 "2017-03-07T16:00:29Z")

</div>

You’re close.

1. Add `index.html` to the root of your site and make sure it has `layout: home`
2. Edit `_layouts/home.html` to loop through the paginator object. `{% for post in site.posts %}` will become `{% for post in paginator.posts %}`

You’ll probably want to add some sort of next/previous links to the `home` layout as well. The link you included above has a complete example that you could replace the entire contents of the home layout with.

```auto

---
layout: default
title: My Blog
---

<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
  <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
  <p class="author">
    <span class="date">{{ post.date }}</span>
  </p>
  <div class="content">
    {{ post.content }}
  </div>
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
  {% else %}
    <span class="previous">Previous</span>
  {% endif %}
  <span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path }}" class="next">Next</a>
  {% else %}
    <span class="next ">Next</span>
  {% endif %}
</div>

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 8, 2017, 12:28am UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/3 "2017-03-08T00:28:10Z")

</div>

Thanks for helping @mmistakes! So, index.html doesn’t have any content in the file except for the following header/frontmatter?

```auto
---
layout: home
---

```

I guess that means index.html just pulls in the contents of `_layouts/home.html` ?

I tried that, and edited `_layouts/home.html` with the markup you mentioned but no luck ☹

I wonder if I am including the gem correctly? Here’s what I included in `Gemfile`

```auto
gem 'jekyll-paginate', "1.1.0"

```

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 8, 2017, 2:01am UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/4 "2017-03-08T02:01:19Z")

</div>

Yeah you can either put it all in the `home.html` layout or copy that code and put it directly in `index.html`. It’s up to you. The Minima theme went with the former which is why I suggested that way.

Are you getting any sort of errors? Have you added the `paginate` settings to your `_config.yml` file along with:

```auto
gems:
  - jekyll-paginate

```

---

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 8, 2017, 3:13am UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/5 "2017-03-08T03:13:08Z")

</div>

Yes, I have this in `_config.yml`

```auto
gems:
- jekyll-feed
- jekyll-paginate
paginate: 5

```

the jekyll-feed gem is working fine…

I’m not getting any errors in terminal related to index.html or the home.html files…

---

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 8, 2017, 7:36pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/6 "2017-03-08T19:36:22Z")

</div>

@mmistakes I did some more digging and I noticed that if I set the template for `index.html` as `default` my homepage is still showing the contents of `_layouts/home.html`

```auto
---
layout: default
---

```

Any idea why that might be?

---

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 8, 2017, 7:47pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/7 "2017-03-08T19:47:31Z")

</div>

Ah! I figured it out. there was a file called `index.md` in the root that was taking priority over the `index.html` file I created. I removed the `index.md` file and everything seems to be working now 🙂

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 8, 2017, 7:49pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/8 "2017-03-08T19:49:36Z")

</div>

That was going to be my next suggestion. It’s a fairly common mistake to have them both. I think `jekyll new` creates `index.md` which can be easily missed if you create your own `index.html` to paginate.

---

<div class="post-metadata">

**Author:** ![saha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/saha/32/105_2.png) [@saha](https://talk.jekyllrb.com/u/saha)\
**Post date:** [March 8, 2017, 8:04pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/9 "2017-03-08T20:04:18Z")

</div>

@mmistakes A quick followup question: I have pagination links working now and the blog archive page (e.g. `blog/page2/`) loads correctly bit it has the same template as `index.html` (`_layouts/home.html`). How can I make the template loaded in `blog/page2/` just use the `default` template?

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 8, 2017, 10:34pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/10 "2017-03-08T22:34:42Z")

</div>

To my knowledge you can’t. The paginated pages are essentially the same thing as index.html but with the appropriate posts. They use the same layout as index.html by design.

---

<div class="post-metadata">

**Author:** ![mrtunes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mrtunes/32/885_2.png) [@mrtunes](https://talk.jekyllrb.com/u/mrtunes)\
**Post date:** [March 21, 2018, 3:36pm UTC](https://talk.jekyllrb.com/t/pagination-question-where-does-index-html-go/262/11 "2018-03-21T15:36:26Z")

</div>

i’m tinkering around here with trying to get pagination to work on the homepage blog feed. do you know why it created all these in the top menu?

![image](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/1X/0e72841bd8606fe0b3c87353f8e5942c7f96faba.png)

and this using the index.html template file that @mmistakes provided above.
