sverrirs / jekyll-paginate-v2

Pagination Generator for Jekyll 3 (enhanced replacement for the old built-in jekyll-paginate gem) ⛺
https://rubygems.org/gems/jekyll-paginate-v2
MIT License
524 stars 289 forks source link

All collections using layout of first collections index found #209

Closed samfoley88 closed 3 years ago

samfoley88 commented 3 years ago

Trying to get multiple collections to paginate I'm getting some odd behaviour where it uses the layout in the first pagination request it finds for all pages.

So for instance I have a number of different collections and for each collection I have a folder with an index that is the same name as the collection but without the underscore. So my events collection has _events with my markdown files and events with index.html that should display that collection. I have the same for "gallery" and "results" collections.

If I only activate pagination for one collection it works fine. As soon as I activate it for more than one the generated index.html's for every collection appear to use the first one it finds (in alphabetical order).

I've tested this by renaming folders and moving the pagination using index.html's around. Whichever index.html it hits first with pagination enabled becomes the one used for all of my index.html's that have collections enabled. Even if its in the root and called something else the same thing still happens.

My index.html's have similar front matter and pagination logic which is basically:

---
layout: page
title: Results
pagination:
  enabled: true
  collection: results
---

{% for result in paginator.posts %}
    <a href="{{ result.url }}">
        <h1 class="title results">
            {{ result.title }}
        </h1>
        <h6 class="date results">
            {{ result.date | date: "%A, %B %e, %Y at %I:%M%P" }}
        </h6>
    </a>
{% endfor %}

Posting in the hope I'm being stupid but happy to add more details and replication steps if nobody can correct me quickly. Also can post original code to an open repo if needed as its an open source project.

salomvary commented 3 years ago

@samfoley88 This seems to be a caching problem when using Jekyll 4. Until the maintainers release a fix you can use one of the forks from #182 or #195 as a workaround.

samfoley88 commented 3 years ago

@salomvary Looks good to me as a fix and definitely explains the issue, my workaround is working for me but I'll close this issue out as those pull requests will definitely fix it when they get approved.