Routes.yml not working

For the last few days I’ve been trying to make custom routes in my routes.yaml, but whatever i’m trying i can’t seem to get the right routes for me to work.

Here’s my full routes.yaml:

routes:
  /: home
  /about/careers/:
    data:
      post: page.about-careers
    template: about-careers

collections:
  /:
    permalink: /{slug}/
    template:
      - index

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

The sections of collections and taxonomies are the default ones. Only routes has been modified.
Once I’ve imported this, or restarted my local Ghost dev installation, I’m only getting a 404 on the page “http://localhost:2368/about/careers/

It would be very helpful if someone can show me an example of a full customized routes.yaml with all the methods to define a route pattern, especially routes that use multi-level URLs.

Have you created and published a page that has the URL about-careers - this would be my first/best guess at why you would correctly be receiving a 404.

Your route reads as follows:

/about/careers/: = create a route at /about/careers/
data: \n post: page.about-careers = pull in the data from the page which has the slug about-careers
template: about-careers = use the template about-careers.hbs

If data isn’t found, then you will receive a 404. Essentially any errors from the data key will “bubble up”.

This allows for setting up a routes.yaml with lots dynamic routes, collections & channels well in advance of the content being created, and the routes only come into existence once the matching data is published.