jekyll-paginate-v2: Can't link to pagination pages
Setup
I’ve installed and set up the plugin but it doesn’t seem to be working correctly. I have the following:
- In guides/index.html I have the following front matter:
---
layout: category
title: Guides Cat
pagination:
enabled: true
category: guides
---
- This page uses “_layouts/category” with the following front matter and pagination from the examples:
---
layout: default
pagination:
enabled: true
---
<main role="main" class="page">
<h1 class="uk-hidden">Homepage</h1>
<div class="uk-container uk-margin-large-top uk-margin-large-bottom">
<div id="pagination">
<div class="cg-grid">
<!-- display posts -->
{% for post in paginator.posts %}
<div>
<div class="uk-card uk-card-default uk-box-shadow-medium">
<div class="uk-card-media-top uk-cover-container">
<img src="{{ post.hero-img | relative_url }}" alt="" uk-cover>
<canvas width="600" height="400"></canvas>
</div>
<div class="uk-card-body">
<h2 class="uk-card-title">{{ post.title | escape }}</h2><span class="uk-label">{{ post.categories }}</span>
{% assign date_format = site.minima.date_format | default: "%b %-d, %Y" %}
<div class="post-meta">{{ post.date | date: date_format }}</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.</p>
<a class="uk-button uk-button-default uk-width-1-1" href="{{ post.url | relative_url }}">Read More</a>
</div>
</div>
</div>
{% endfor %}
</div>
<!-- trail -->
<ul class="uk-pagination uk-flex-center">
{% if paginator.page_trail %}
{% if paginator.previous_page %}
<li class="previous">
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}"><span uk-pagination-previous></span></a>
</li>
{% endif %}
{% for trail in paginator.page_trail %}
<li {% if page.url == trail.path %}class="uk-active"{% endif %}>
<a href="{{ trail.path | prepend: site.baseurl }}" title="{{trail.title}}">{{ trail.num }}</a>
</li>
{% endfor %}
{% if paginator.next_page %}
<li class="next">
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}"><span uk-pagination-next></span></a>
</li>
{% endif %}
{% endif %}
</ul>
<!-- end of pagination test -->
<div>{{ page.categories }}</div>
</div><!-- .cg-grid -->
</div><!--/ cg-container -->
</main>
The ‘_layouts/category.html’ then uses ‘_layouts/default.html’ as follows
<!DOCTYPE html>
<html lang="{{ page.lang | default: site.lang | default: "en" }}">
{% include head.html %}
<body>
{% include header.html %}
{{ content }}
{% include footer.html %}
<script src="https://code.jquery.com/jquery-3.2.0.min.js" integrity="sha256-JAW99MJVpJBGcbzEuXk4Az05s/XyDdBomFqNlM3ic+I=" crossorigin="anonymous"></script>
<!-- <script>window.jQuery || document.write('<script src="lib/jquery_3-2-0.min.js"><\/script>')</script> -->
<script src="{{ "/assets/js/uikit.min.js" | relative_url }}"></script>
<script src="{{ "/assets/js/uikit-icons.min.js" | relative_url }}"></script>
<script src="{{ "/assets/js/main.js" | relative_url }}"></script>
</body>
</html>
The Problem
If I browse directly to the URL localhost:4000/guides/index.html the pagination works and page is displayed.
If I add a link in my _includes/header.html to this page like so:
{% link guides/index.html %}
I get the following error:
Liquid Exception: Could not find document 'guides/index.html' in tag 'link'. Make sure the document exists and the path is correct. in /_layouts/default.html
...error:
Error: Could not find document 'guides/index.html' in tag 'link'. Make sure the document exists and the path is correct.
Error: Run jekyll build --trace for more information.
[2018-05-26 09:05:38] ERROR `/_includes/header.html' not found.
I’ve tried simply using
<a href="guides/index.html">Guides</a></li>
and this works, but every time I click on the link I get an extra guides/ added to the path, for example:
guides/guides/guides/guides/index.html
Link has been clicked three times.
I’ve been trying to get this working myself and I just can’t understand what’s happening here; everything looks ok to me, and seems analogous with the examples. Not sure if I’m doing something wrong or if this is a bug.
Any help would be greatly appreciated.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 19 (2 by maintainers)
@mkpankov @ibrado I also had the problem of duplicates in the path, but this was when using html urls instead of link. This was because of a missing leading slash. Every time I clicked on the link it would add to the path like this:
and so on. The link works fine with the leading slash.
@ibrado I’ll create a repo for my site later on this week if that’s any use to you for testing.