Closed parkr closed 9 years ago
Voting yay on this.
+1
+1 pretty please. One of my biggest frustrations with Jekyll would be solved by this. In most cases You can do without pagination but sometimes it would be quite handy (ton of content)
Thanks for the +1's. How would you envision pagination working?
+1 for that definitly! +1 for paginate categories
Vote for it :)
:+1:
As far as the technical implementation, I don't have a clue but, since pagination should ideally be available in multiple places (posts, collections, categories), I guess you'd have to go beyond the existing paginator variable.
Ideally (and this is probably very difficult to implement), I'd like a looping tag pair that you could then use with any array / object (post / collections / categories). Something along the lines of:
provided you have an _albums collection
{% paginate site.albums as albums limit:5 %}
{% for album in albums %}
... display album data ...
{% endfor %}
{% if paginate.previous %}
<a href="{{ paginate.previous_path | prepend: site.baseurl | replace: '//', '/' }}">Previous</a>
{% endif %}
{% if paginate.next %}
<a href="{{ paginate.next_path | prepend: site.baseurl | replace: '//', '/' }}">Next</a>
{% endif %}
{% endpaginate %}
I agree with @jeromecoupe. Great idea :+1: . Can try to give some help my self but will take time because I am just 2 days old for Jekyll
Would love to see this.
:+1: I would also love to see this.
:+1: sounds good.
Happy to look at a PR :)
Not sure if this is too off-topic, but since I arrived here via Google looking for a solution to collection pagination, I figured I'd post a workaround incase anyone else was in the same boat as me.
It is possible to manually paginate using both limit
and offset
on the for
loop.
My code:
{% for item in items limit:10 %}
And then in a manually created page-2.html
file:
{% for item in items limit:10 offset:10 %}
page-3.html
:
{% for item in items limit:10 offset:20 %}
etc.
:+1:
+1 for the solution proposed by @jeromecoupe (kudos to @sambaldwin for an easy work-around but I'm 100% in favor of making this a more universal feature)
:+1:
:+1:
:+1:
:+1:
@parkr why was this closed? Where's the work on collection pagination, if any, being tracked in future?
Add me as interested in this as well :)
And me.
I also didn't understand why the issue is closed ...
Thanks @gynter, please note that the issue was closed a month ago, while that announcement was done 10 hours ago. So it's clear now it, but we can agree it was a weird timeline of communication. It would be nice to update the README.md with a deprecation notice with a link to that forum and later a link to replacement, thanks again!
You can include pagination by including some liquid logic into the layout of your collection. For example, I have a collection called "_portfolios" where I will hold all of my portfolio items. Each portfolio item has yml like this:
`--- title: Landscape subtitle: Photography layout: portfolio
cta: btnText: View Services btnType: btn-warning btnLink: /about/
images:
In layouts > portfolio.html
I have the following includes to use a widget I made:
{% include collection-pagination.html collection="portfolios" %}
The liquid logic in collection-pagination.html is:
` {% assign this_collection = include.collection %} {% for c in site.[this_collection] %} {% if c.title == page.title %} {% assign thisPost = c %} {% if forloop.index == 1 %} {% assign prevflag = 0 %} {% assign nextflag = 1 %} {% elsif forloop.index == forloop.length %} {% assign prevflag = 1 %} {% assign nextflag = 0 %} {% else %} {% assign prevflag = 1 %} {% assign nextflag = 1 %} {% endif %} {% endif %} {% endfor %}
{% for c in site.[this_collection] %} {% if c.title == page.title %} {% assign prevflag = 0 %} {% endif %} {% if prevflag == 1 %} {% assign prevPost = c %} {% assign page.previous = c %} {% endif %} {% endfor %}
{% if nextflag == 1 %} {% for c in site.[this_collection] %} {% if foundPost == 1 %} {% assign getNext = 1 %} {% endif %} {% if c.title == page.title %} {% assign foundPost = 1 %} {% endif %} {% if getNext == 1%} {% assign nextPost = c %} {% assign page.next = c %} {% assign foundPost = 0 %} {% assign getNext = 0 %} {% endif %} {% endfor %} {% endif %}
This generate two buttons that you can style. The neat part is that if you are at the first item of the collection, the "previous" button will be disabled and hidden. If you are at the last item of a collection, the "next" button will be disabled.
I learned about this from: anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/
I've been trying to paginate a masonry layout image-board that iterates through every file in an image folder and it feels way more complicated than it should be... I've been using paginate v2
@weevil Paginate v2 is a different project entirely: https://github.com/sverrirs/jekyll-paginate-v2
Allow users to paginate collections!