Better dynamic URL routing for sub pages?

Currently, I’m rolling out multiple ghost instances to migrate sites from one CMS to Ghost. I have not been using Ghost to curate blog-type posts, but more to serve up static pages. Within the routes.yaml. I have manually mapped out pages and their subpages as follows:

image

Is there a way to route sub-pages more dynamically? For example, if I publish a page/post such as “fun-facts” with the tag “about”, it would dynamically route to “/about/fun-facts”. Thank you for your help in advance. -JP

If you create them as posts rather than pages then you could treat them as a collection

collections:
  /about/:
    permalink: /about/{slug}/
    template: page
    filter: primary_tag:about
1 Like

Thank Kevin. My brain thinks pages not posts. I will give that a shot with the next site I have to migrate over shortly.

UPDATED: I’ve got it working how it should now. Thanks for the help Kevin.


Hi Kevin, I did manage to play around with collections a bit. I can get the routing to work pretty well, but this doesn’t do much with the data of a page or post. Is there any way to pull in data from a page or post dynamically than directly referring to the page or post in routes using … data: post.about ?

I feel like I am fighting for a crumb of bread here. This should be easier. I have several newsletters and want to nest them under /newsletters. The most I got so far gives me an URL /newsletters/2021-09-06-newsletter1/, which is not nice.