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:

routes.yaml

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

post.hbs

{{#post}}
  <h1>{{title}}</h1>
  {{content}}
  {{#prev_post in="primary_tag:food"}}
    <a href="{{url}}">
      Previous
      {{title}}
      {{primary_tag.name}}
    </a>
  {{/prev_post}}

  {{#next_post in="primary_tag:food"}}
    <a href="{{url}}">
      Next
      {{title}}
      {{primary_tag.name}}
    </a>
  {{/next_post}}
{{/post}}

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.