Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination doesnt work on a collection page #84

Open
hosnas opened this issue Mar 7, 2018 · 13 comments
Open

Pagination doesnt work on a collection page #84

hosnas opened this issue Mar 7, 2018 · 13 comments

Comments

@hosnas
Copy link

hosnas commented Mar 7, 2018

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?

@woutrbe
Copy link

woutrbe commented Mar 22, 2018

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.

@sverrirs
Copy link
Owner

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 :)

@woutrbe
Copy link

woutrbe commented Mar 22, 2018

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:

  1. How do I do this for categories where I have a custom post list
  2. 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.

@hosnas
Copy link
Author

hosnas commented Mar 22, 2018

@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.

@renshuki
Copy link

renshuki commented Apr 4, 2018

@hosnas Isn't this already supported by AutoPages addon?

@hosnas
Copy link
Author

hosnas commented Apr 5, 2018

@renshuki I don't think so. How?

@joshdick
Copy link

joshdick commented Aug 16, 2018

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: '//', '/' }}">&laquo; Prev</a>
  {% else %}
    <span>&laquo; 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 &raquo;</a>
  {% else %}
    <span>Next &raquo;</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.

@joshdick
Copy link

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.

@spero-cnet
Copy link

spero-cnet commented Aug 16, 2018

@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 -->

@joshdick
Copy link

@spero-cnet That indeed happened to me and your code did the trick, thanks for the tip.

@vcavallo
Copy link

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.

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 :) )

@joshdick
Copy link

@vcavallo You're welcome!

@pixelicous
Copy link

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants