سؤال

On the following Jekyll site, artdiversions.com, I have pagination on the index page. If you go to page 2, and from that page, click "Older Posts", it takes you back to artdiversions.com/index.html. This is the only page that doesn't use pretty permalinks. Is there a way to remove the "index.html" and keep the site root on page 1. My paginator code is:

{% if paginator.total_pages > 1 %}
 {% if paginator.previous_page %}
    <p class="col-1-2 old-arrow"><span class="icon-arrow-left"></span><a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">Older Posts</a></p>
 {% endif %}

 {% if paginator.next_page %}
   <p class="col-1-2 new-arrow"><a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Newer Posts</a><span class="icon-arrow-right"></span></p>
 {% endif %}
{% endif %}
هل كانت مفيدة؟

المحلول

On my site I use an explicit check to workaround this issue. My code is:

{% if paginator.previous_page %}
  {% if paginator.previous_page == 1 %}<a href="/">Newer →</a>
  {% else %}<a href="{{ paginator.previous_page_path }}">Newer →</a>
  {% endif %}
{% endif %}

We seem to have differences in what is counted as newer.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top