jekyll-paginate icon indicating copy to clipboard operation
jekyll-paginate copied to clipboard

previous_page_path includes index.html

Open rovrov opened this issue 11 years ago • 7 comments

Moved from https://github.com/jekyll/jekyll/issues/3073

paginator.previous_page_path generates base/page2 when on the third page, but for the second page the result is base/index.html which is not pretty. Shouldn't previous_page_path generate just base/ in this case?

Here is a sample fix: https://github.com/rovrov/jekyll-paginate/commit/088fd180a32b32376dd3aab4fff388431fd6d249

~~base instead of base/ (i.e. chomp("/index.html")) might be even more consistent if it always works without the trailing slash.~~

rovrov avatar Nov 09 '14 20:11 rovrov

My only concern here is that not everyone will want this.

parkr avatar Nov 09 '14 22:11 parkr

The way I see it, the following options are consistent:

  • base/page2/ and base/
  • base/page2/index.html and base/index.html

I don't know why anyone would want to have a mix between the two.

Also, base/page2 without the trailing slash is not great because GH first responds 301 "Moved Permanently" --> base/page2/ and then an additional request to base/page2/ happens.

rovrov avatar Nov 09 '14 23:11 rovrov

Yeah the consistency makes sense for sure.

The 301 may not be Jekyll. What permalink style do you have set in your config.yml? Maybe we need to default to /base/page:num/

parkr avatar Nov 10 '14 00:11 parkr

I was using paginate_path: "blog/page:num" that I took from http://jekyllrb.com/docs/pagination/. It should indeed be "blog/page:num/", could you update the docs as it is misleading? Not sure about the defaults - doesn't work for me if I don't set a paginate_path.

There is nginx keyword in the 301 response-body, anyway 301 is the right thing in this case.

I just realized someone might have set paginate_path: "blog/page:num/index.html", and then "blog/index.html" would be appropriate for the first page. The question is if people actually do this.

rovrov avatar Nov 10 '14 03:11 rovrov

It should indeed be "blog/page:num/"

Yeah, we can update the docs. Would you mind submitting a PR? The docs are in jekyll/jekyll in the master branch in the site/_docs/pagination.md file.

I just realized someone might have set paginate_path: "blog/page:num/index.html", and then "blog/index.html" would be appropriate for the first page. The question is if people actually do this.

I don't think anyone does this, but we can't be sure.

parkr avatar Nov 10 '14 19:11 parkr

Submitted: https://github.com/jekyll/jekyll/pull/3091

Concerning the base/index.html issue, just want to add that other people also had to fix it and blogged about this: http://www.ericlagergren.com/blog/jekyll-pagination/ | replace: 'index.html', '/'

http://www.paulwrankin.com/blog/2014/10/16/better-jekyll-pagination/ {% if paginator.previous_page == 1 %}

rovrov avatar Nov 10 '14 21:11 rovrov

This is fixed for Jekyll > 3.0

neoascetic avatar May 03 '16 19:05 neoascetic