How to pagination posts in a collection?

I have collections set up for a couple different primary tags, and I’m trying to figure out how to paginate only within the context of that collection when viewing a post. The official docs suggest that I can use {{#prev_post in="primary_tag"}}, although it doesn’t actually work—it still traverses posts with any tag.

Here’s my setup:


    permalink: /food/{slug}/
    template: category-food
    filter: primary_tag:food
  tag: /{slug}/


  {{#prev_post in="primary_tag:food"}}
    <a href="{{url}}">

  {{#next_post in="primary_tag:food"}}
    <a href="{{url}}">

I’ve also tried food instead of primary_tag:food as the filter, but neither seems to have any effect. Am I doing something wrong here, or is it impossible to filter pagination within a collection?

So this is about prev_post and next_post and not pagination, right?

From the docs, it looks like the syntax is like this:

{{#prev_post in="primary_tag"}}

No need to specify the tag, or replace it with the tag name, that should be taken care of in the background. This will take your current posts’ primary_tag and fetch the previous/next post in that tag.

Ah yes, I guess “pagination” probably isn’t the right word—prev_post and next_post is what I mean.

The docs were, after all, correct! I just assumed primary_tag was a placeholder for the slug of a primary tag. Works like a charm! Thanks for your response.