Using #get + filters on homepage while keeping pagination

Our use case looks like this:

The index / only displays posts with an internal tag. We’re doing this via #get

{{#get 'posts' limit=@config.posts_per_page filter="tags:hash-blog"}}

The problem is that, according to the docs, #get doesn’t work with pagination. Right now the pagination just displays the same content over and over for each page. We could mess with collections, but we don’t want all of our non-blog posts to have collection-specific urls. We’d like all posts to view the same /{slug} regardless.

As a result it seems like the two options are:

  • Filter like we’ve been doing, and give up on pagination for the home page.
  • Filter via the routes configuration, but that results in all non-blog pages never rendering, so they then need to be caught by a separate collection. This means new urls for all of those non-blog tagged posts.

Is there an approach I’m missing? I feel like using page in the #get could work, but I’m not sure how to access the current pagination value directly in the #get. Thanks!

Have you looked into Channels much @markmichon? Seems like it could work really well for your situation:

1 Like

Thanks David, that worked :+1:.

It’s not super clear in the docs that you can apply channels and collections to the same route. For anyone else, the solution looks something like this:

    controller: channel
    filter: "tag:hash-blog"
    permalink: /{slug}/
    template: index
1 Like