jekyll-paginate-v2
                                
                                 jekyll-paginate-v2 copied to clipboard
                                
                                    jekyll-paginate-v2 copied to clipboard
                            
                            
                            
                        Pagination doesnt work on a collection page
I want to use some of my collection pages to show pagination of other collections. but it seems this plugin doesnt support this functionality. Any reason why? and any chance it could be considered as a feature request?
I'm currently facing the same issue, even though I've added
pagination:
  enabled: true
to the front matter of all my collection pages, the paginator won't pick it up.
Just to clarify, my site structure is as follows:
- _products
  - product1.md
  - product2.md
- _types
  - electronis.md
  - outdoor.md
_products have the following front matter
types:
  - electronics
  - outdoor
In my _types template I can easily get all the products
{% assign products = site.products | where_exp: "product", "product.types contains page.slug" %}
But how do I get pagination to work? None of the solutions or examples seem to work. I'm getting slightly confused as this doesn't seem like a unusual use-case.
Hi, could you please provide me with a repro of this issue in a git repo somewhere or a zip file that I can test out. This may be a configuration that I hadn't anticipated and it is impossible to figure out why this is going wrong without being able to debug the exact issue :)
I just created a new project to show my configuration: https://github.com/woutrbe/jekyll-pagination Basically I want to paginate all category pages under http://127.0.0.1:4000/categories
But a few questions:
- How do I do this for categories where I have a custom post list
- Even with pagination enabled in the layout, jekyll complains about Is enabled, but I couldn't find any pagination page.
Let me know if the example is clear enough.
@sverrirs as per here collection docs aren't considered as a candidate for pagination. it means pagination can be only enabled in pages. I hope this would be enhanced to include collection docs too.
@hosnas Isn't this already supported by AutoPages addon?
@renshuki I don't think so. How?
I'm having the same issue.
The collection I'm trying to paginate is called microblog. In the example below, /_microblog/index.html is not seen by jekyll-paginate-v2 even though it has pagination configuration in its front matter.
I don't see the Is enabled, but I couldn't find any pagination page. warning unless I explicitly enable pagination in the root _config.yaml, but regardless of what _config.yaml says, the pagination configuration in the front matter in /_microblog/index.html appears to be completely ignored.
Here's my setup, all relative to a top-level directory:
/Gemfile:
source 'https://rubygems.org'
gem 'jekyll'
gem 'jekyll-paginate-v2'
/_config.yml (note that there's no pagination-related configuration here):
collections:
  microblog:
    output: true
exclude: ['Gemfile', 'Gemfile.lock']
kramdown:
  entity_output: numeric
sass:
  style: compressed
  sass_dir: _sass
plugins:
- jekyll-paginate-v2
/_microblog/posts: (Contains a bunch of Markdown files)
/_microblog/index.html:
---
layout: default
title: Microblog
pagination:
  enabled: true
  collection: microblog
---
<br />
<h1>Microblog</h1>
{% for post in paginator.posts %}
  <h1>{{ post.content }}</h1>
{% endfor %}
{% if paginator.total_pages > 1 %}
<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">« Prev</a>
  {% else %}
    <span>« Prev</span>
  {% endif %}
  {% for page in (1..paginator.total_pages) %}
    {% if page == paginator.page %}
      <em>{{ page }}</em>
    {% elsif page == 1 %}
      <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a>
    {% else %}
      <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
    {% endif %}
  {% endfor %}
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Next »</a>
  {% else %}
    <span>Next »</span>
  {% endif %}
</div>
{% endif %}
<!-- Unrelated content follows -->
I hope that's a clear example that demonstrates the issue, but I'm happy to clarify anything if needed.
@sverrirs
Edit: Had stuff left over from an autopaging experiment in my _config.yml that I didn't mean to paste here, I've removed it from the example code.
Figured it out.
Based on my example above, my existing /_microblog/posts folder needed to only contain the Markdown files, but I needed to move index.html to /microblog/index.html to get pagination to work (as opposed to /_microblog/index.html where it was before -- no underscore.)
Other resources not mentioned in my example above that used to be in /_microblog (RSS feed, etc.) also needed to be moved to /microblog so that jekyll-paginate-v2 wouldn't try to also paginate them.
tl;dr posts need to be inside /_collectionName/posts, but the page to be paginated needs to live in /collectionName.
@joshdick you might also need to add a string filter to remove /index.html if your _config.yml is set to expressionless urls (pretty)- which paginate v2 does not seem to honour.
<!-- PAGINATION -->
{% if paginator.total_pages > 1 %}
<div class="row">
	<div class="col-sm-12 text-center m-t-40 m-b-40">
		<ul class="pagination font-alt">
			{% if paginator.previous_page %}
			<li><a href="{{ paginator.previous_page_path | prepend: site.baseurl }}"><i class="fa fa-angle-left"></i></a></li>
			{% endif %}
			{% if paginator.page_trail %}
				{% for trail in paginator.page_trail %}
					<li {% if page.url == trail.path %}class="active"{% endif %}>
						<a href="{{ trail.path | prepend: site.baseurl | remove: "index.html" }}" title="{{trail.title}}">{{ trail.num }}</a>
					</li>
				{% endfor %}
			{% endif %}
			{% if paginator.next_page %}
				<li><a href="{{ paginator.next_page_path | prepend: site.baseurl }}"><i class="fa fa-angle-right"></i></a></li>
			{% endif %}
		</ul>
	</div>
</div>
{% endif %}
<!-- /PAGINATION -->
@spero-cnet That indeed happened to me and your code did the trick, thanks for the tip.
Figured it out.
Based on my example above, my existing
/_microblog/postsfolder needed to only contain the Markdown files, but I needed to moveindex.htmlto/microblog/index.htmlto get pagination to work (as opposed to/_microblog/index.htmlwhere it was before -- no underscore.)Other resources not mentioned in my example above that used to be in
/_microblog(RSS feed, etc.) also needed to be moved to/microblogso thatjekyll-paginate-v2wouldn't try to also paginate them.tl;dr posts need to be inside
/_collectionName/posts, but the page to be paginated needs to live in/collectionName.
Thank you thank you. I was having the same issue and searching all over this repo was not helping. Your comment was the only thing that cleared it up (well, your comment and taking a lunch break before deep frustration set in :) )
@vcavallo You're welcome!
Figured it out.
Based on my example above, my existing
/_microblog/postsfolder needed to only contain the Markdown files, but I needed to moveindex.htmlto/microblog/index.htmlto get pagination to work (as opposed to/_microblog/index.htmlwhere it was before -- no underscore.)Other resources not mentioned in my example above that used to be in
/_microblog(RSS feed, etc.) also needed to be moved to/microblogso thatjekyll-paginate-v2wouldn't try to also paginate them.tl;dr posts need to be inside
/_collectionName/posts, but the page to be paginated needs to live in/collectionName.
Thanks.. was stumbling upon this as well.. it did seem from #104 that it could be fixed in other ways, but couldnt get that to work