Open XiminLin opened 2 years ago
I had this same problem, I found this helpful paragraph that looks to be from an old version of the README.md, quoting below:
If you specify multiple pages that paginate in the site root then you must give them unique and separate pagination permalink. This link is set in the pagination page front-matter like so
pagination:
enabled: true
permalink: '/cars/:num/'
Make absolutely sure that your pagination permalink paths do not clash with any other paths in your final site. For simplicity it is recommended that you keep all custom pagination (non root index.html) in a single or multiple separate sub folders under your site root.
Following up, this was not the fix.
I had the same issue when paginating multiple categories according to different templates. I found a trick that may bypass this issue. After some trial and error, I found the paginator works normally when using the templates in _layout
directory. So if we put everything in the _layout
and create an empty file only with front matter, things might work.
Take the 02-category
for example. The category
directory has four files, and these four files should generate 4 pagination pages. I found that if I write something in each file, for example, name test {{paginator.total_pages}}
in byname.md
and porsche test {{paginator.total_posts}}
in porsche.md
. The output pagination pages should be different, but one will overwrite the other as shown below.
What I did is that I created another layout home_porsche.html
for porsche.md
only, change layout: home_porsche
in porsche.md
, and leave the rest blank. In this way, the overwrite disappers. The paragraph in porsche.html
is written in the layout HTML file.
I use the same method on my own project. It works. Hope it can help.
@yuhan16 Thanks. That was the workaround for me.
I ran into this issue today. After some testing, I believe this is resolved by #210. So, you can fix it by referring to the most recent commit (or just the main branch) in your Gemfile:
gem "jekyll-paginate-v2", git: "https://github.com/sverrirs/jekyll-paginate-v2", ref: "7bc2634c04c49120b674cc3506275f85c4389f5c"
Would love to see a new version released that includes this fix!
I don't think #210 is the full fix; liquid rendering uses caching based on document.path
. (Have fun tracking that sh.. through the jekyll codebase.)
You always need to set a proper path, for each (paginaged) page.
That Jekyll::Page
has a @path
with the absolute path, but only returns a magical relative path in .path
.. well. Sucks.
After
bash bundle exec jekyll serve
, upon inspecting the project page, the project page can display _projects correctly (the front matters are used correctly), but the html code is totally from index.html.This is my directory strcture:
index.html is the main page showing all my posts. projects.html should show all my projects. Both use default.html as layout. Both use pagination: index.html displays _posts; projecs.html displays _projects.
This is my index.html
This is my project.html
After
bash bundle exec jekyll serve
, Under the_site
folder:I suppose
projects/index.html
should come from my/projects.html
, This is the code generated inprojects/index.html
:You can see that projects/index.html is using index.html's code and projects.html's front matter.
Why is this the case and how should I change this so that I can use projects.html's code?
Thank you