Page prevsibling nextsibling inverted

Hi all, again coming with a stupid strange thing…
My site blogs are perfectly working, organized with numeric prefix.
When serial showing pictures of all post, they all show in a good order O1- 02- etc.
When clicking one, you have prev/next based on some very standard code :

{% if not page.isFirst %}
  <div class="nav-previous" id="navPrevious" pageref="{{ page.prevSibling.url}}"...
{% endif %}
{% if not page.isLast %}
  <div class="nav-next" id="navNext" pageref="{{ page.nextSibling.url}}" ...
{% endif %}

So… Does anyone have any idea why next and prev are inverted ?! What did I touch to have this behavior ? :crazy_face:

thanks for any reply :wink:

Have you had a look at the quark blog-item.html.twig, is slightly different and always good to use quark as a reference point as it is updated / check for compatability for each release.

<p class="prev-next text-center">
{% if not page.isLast %}
        <a class="btn" href="{{ page.prevSibling.url }}"><i class="fa fa-angle-left"></i> {{ 'THEME_QUARK.BLOG.ITEM.PREV_POST'|t }}</a>
{% endif %}

{% if not page.isFirst %}
    <a class="btn" href="{{ page.nextSibling.url }}">{{ 'THEME_QUARK.BLOG.ITEM.NEXT_POST'|t }} <i class="fa fa-angle-right"></i></a>
{% endif %}

What theme are you using where the problem occurs ?

Looks like the THEME_QUARK.BLOG.ITEM.NEXT_POST and THEME_QUARK.BLOG.ITEM.PREV_POST’ might need a bit of explanation, but to this untrained eye is using a variable of where the blog directory lives

THEME_QUARK.BLOG.ITEM.PREV_POST button - Support / Themes & Styling - Grav Community Forum (

I am sure pamtbaau will be able to tell you straight away, but it looks like where the location of the root of blog lives and query the next posts either side , then sends itself back to the blog (blog-item.html.twig)

as in the example site of the person who put the question in above

<p class="prev-next"><a class="button" href="/seo/ouvrir-url-masse"><i class="fa fa-chevron-left"></i> Article suivant</a>
<a class="button" href="/seo/exemple-negative-seo">Article précédent <i class="fa fa-chevron-right"></i></a></p>

from the site Spécialiste SEO (SEO Specialist) | Merci Serguey (

(spamhater, you again :yum: thanks for answering. )
So to answer the theme is a one I develop, based on grav skeleton when asking for creating a new one.

The Quark sample you mention is giving the same behavior. clicking the next page sibling will show the previous.
May be I’m a little to dumb to understand by myself, but if I read and translate correctly the code :
if the page is NOT LAST then show a previous button
if the page is NOT FIRST then show a next button

–not last--------------not first –
— <<<<— my page —>>>> ----

isn’t that reversed ?

@Francois, IMHO, I think the behaviour is exactly as expected…

To quote the first hit on Google:

Definition | Meaning of blog:

A blog (a shortened version of “weblog”) is an online journal or informational website displaying information in reverse chronological order, with the latest posts appearing first, at the top. It is a platform where a writer or a group of writers share their views on an individual subject.

So, when showing a single blog item, the Previous is the one written before the current and the Next is the one written after the current.

You are using the Blog related templates designed for a Blog, however, you are not using it as a Blog.

In your use-case, or misuse-case, the way you order the items give a different meaning to Previous and Next. You should therefor adapt the templates to fit your meaning of Previous and Next.

1 Like

@pamtbaau @spamhater
Oh yes of course ! That’s what I forgot, blog is basically ordered by reverse “publication” date and not by numeric name or folder. That’s the point.
{% for child in p.collection %} is giving a name ordered,
next or prev sibling, the classic blog ordering has formally defined.

And in my case, as all pages where created in a chronologic order, then prev/next seems to be reversed (but is not :slight_smile:).
Thanks for explanations, and you’re right, I will adapt my specific templates.