Search code examples
ghost-blog

Ghost — display posts with specific tag in index


I want to hide posts with certain tag from the index. Let's say I have two categories on my site: "news" with daily posts and "long-reads" with weekly posts.

I want my index to display only "long-reads" and have separate section for "news".

There is a couple solutions mentioned here, but they're insufficient:

  1. {{get}} helper doesn't support pagination
  2. Filtering posts inside {{foreach}} also affect pagination—for instance if I have 7 "news" and 1 "long-read" in the past week, my first page will contain only single post, despite the fact I have a bunch of old "long-reads".

What is the best solution to achieve this? Maybe stick index to tag page?


Solution

  • This can be easily achieved by utilizing Dynamic Routing. More precisely, Collections and Channels. The difference between them is that Post can exist only in one Collection, e.g. "video", "article" or "podcast" because putting Post in Collection changes it URL, while Channel is more like "saved" search result e.g. "reviews" which can include both videos and articles and Post doesn't changed URL.