Skip to main content

Separating blog posts by tag with pagination

I have a client site that has numerous categories/tags of posts that I want to display on various pages of the website. For ease on their end, I want to set up one main blog where they post everything, and then have the posts parse out to the various pages on the site by tag. The issue is that it seems that I want to combine the functions of the liquid "subpage" call and the "tag" one. I want each separate page to display the posts with one certain tag, but I want to retain the functionality of a blog page so that the posts paginate. As I understand it, if I use the "tag" call (on a basic page), they won't paginate, and if I use "subpage" they won't be separated by tag. I thought about using the built-in pages that list posts and pages by tags, but I don't want the word "tags" in the URL of all the website's pages. How can I accomplish this? Thanks!

Official response from

Hi Alison!

When using the {% tag %} call, you should be able to add pagination to it. For the proper syntax, check out the "tags_show.html" file in any stock theme. Here's a gist of that file in my theme: https://gist.github.com/bpalm/1689f9b0cf97b6b972cfb4e048a81b4b

As you can see, the following liquid drop, when added to the bottom, adds pagination:

{{ tag.most_recent_published_pages | paginate }}

In fact, you may want to just utilize the already existing tags_show.html file, which displays a listing of all pages with a given tag at slug.nationbuilder.com/tags/tagname. You could tweak the markup in the tags_show.html file to change the formatting, but the functionality sounds like what you are trying to accomplish. If you don't want the word 'tags' in the URL, you can create new basic pages that just include the following code in the template:

{% tag 'tagname' with 'tags_show' %}

This may require that you make a new file called "_tags_show.html" and fill it with the content from the "tags_show.html" file, as the leading underscore is needed here.

Here's more detailed information about the {% tag %} tag.

Another solution, albeit much more complicated, has been outlined by another NationBuilder customer here: Next and Previous links for blog posts

Share this post

Showing 2 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.