-
Notifications
You must be signed in to change notification settings - Fork 292
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
jekyll-paginate-v2 doesn't handle pages properly #104
Comments
Hi Mike, thank you very much for this detailed analysis and to take the time to debug this issue. Do you think you have time to code a fix and do the possible refactorings involved? I'd be happy to accept a PR for a fix. I'm unfortunately a bit busy with other life things and can't look into this for a while. :/ |
For the The |
Thank you Mike. Any help/time you can spare is much appreciated :) |
@6twenty Where did you get that information?? |
Hey @ashmaroli - yep, you're right. This is the way we've done it for a while as it helped us keep our project organised a little better, but in looking into it this is actually more of a workaround than a supported feature. See jekyll/jekyll#920 (comment). Interestingly the comment suggests that these pages should still get added to There does seem to be some desire to make _pages officially supported - this PR has a label of "Priority 2 (should)". At any rate considering this isn't an official feature at this stage I'm happy to accept that jekyll-paginate-v2 doesn't need to concern itself with it. Hopefully it gains proper support soon 🤞 |
@6twenty As of the latest release, when you add a |
There are 2 parts to this problem:
_pages/
directory.dir
for its pagination pages.1.
Jekyll now supports defining your site's regular pages under a special top-level
_pages/
directory. For the most part Jekyll treats these no differently to pages that are located elsewhere, except for one key difference: these pages aren't exposed undersite.pages
. The reason is that files within_pages/
are treated as Document objects, while other pages are Page objects. The Document pages must be accessed viasite.collections['pages']
instead; jekyll-paginate-v2 however only looks atsite.pages
to try to find its pagination pages.I suspect jekyll-paginate-v2 is fairly heavily dependent on this approach though given that it sub-classes
Page
for its ownPaginationPage
class, so it would need some refactoring to support Document classes as well.2.
To work around the problem above, the pagination pages must be defined outside of the
_pages/
directory. In my case I have a collection of posts under the "news" category that I want to paginate, so I simply usenews/index.html
instead of_pages/news.html
. The Page object that gets created will havepage.dir #> '/news'
, however when jekyll-paginate-v2 clones the page, it will havepage.dir #=> '/'
instead. This has a knock-on effect:page.relative_path
will now beindex.html
instead ofnews/index.html
, and this in turn breaks the ability to use thelink
helper. E.g.This should work, but will instead raise an exception that the page can't be found. This is because Jekyll compares the
relative_path
of each file, but the relative_path for the cloned pagination page is now incorrect. This stems from this line:Instead of copying the
dir
, it's getting the parent directory name instead.Related issue: #93
The text was updated successfully, but these errors were encountered: