Ghost Subtopics

Hello all,

I just started with Ghost. I am trying to create a subtopic or subpath? Essentially when I create a new post with the “daily-news” tag, I want to have that accessible only by https://www.domain.com/daily-news/{slug}

What I’ve done is modified the routes.yaml:

routes:

collections:
  /:
    permalink: /{slug}/
    template: index
  /daily-news/:
    permalink: /daily-news/{slug}/
    filter: primary_tag:daily-news

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Is this right? When I tried it, it doesnt seem to creating that sub path of /daily-news/, (e.g https://www.domain.com/daily-news/december-16)

Self hosting using docker.

Putting the ‘/daily-news/’ before ‘/’ in collections will work.

1 Like

That did it! So simple! Thank you!

For anyone reading this later, here’s the deal:

Collections are exclusive. A post can only be in one collection.
Posts are assigned to collections starting at the top of the list. In the original routes.yaml, all posts were assigned to the /: route, since there was no filter on it, so there were no posts for the /daily-news/: route. Switching the order allowed the daily-news route to take the daily-news-tagged posts.
Another solution would be to all filter: primary_tag:-[daily-news] to the /: route.

Two bonus tips:

  1. Posts that aren’t assigned to any route don’t get a nice slug. They get a random-looking 32-character uuid, like yoursite/p/0bea5f67-880d-44c8-9ee7-9a19e6d4dfed. Always make sure your posts land on some route, if you want to be able to give them a human-readable slug. (This is a good argument for making the last route have no filter on it.)
  2. If you ever want posts to show up in multiple places (perhaps you have daily-news that is also sports-news), check out channels. They’re not exclusive, so a post can belong to multiple channels. (Each one still needs to be in a collection so that it’ll get a nice url.)
3 Likes