I’ve been trying to get my page collections to work but I just cannot get it right.
Basically I just want a simple Next/Previous navigation on my article headers.
I found the example on GitHub. All of my articles are assigned the same taxonomy (category: blog). I also double checked and made sure category was defined in my site.yaml file.
In my header.html.twig file I copied the example exactly:
{% set progress = page.collection({‘items’:{’@taxonomy’:{‘category’: ‘docs’}},‘order’: {‘by’: ‘default’, ‘dir’: ‘asc’}}) %}
{% if not progress.isFirst(page.path) %}
Next
{% endif %}
{% if not progress.isLast(page.path) %}
<a class="nav nav-next" href="{{ progress.prevSibling(page.path).url }}">Previous</a>
{% endif %}
It just refused to work and I’m stumped. The links will only have urls for the current page. I know it’s probably really simple, but I’m new to this and have hit a wall. Any help is much, much appreciated. Thanks!