Routing and passing PAGE_NAME.data via routes.yaml

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be closed.

If you aren’t running the latest version of Ghost, the first thing we will ask you to do is update to the latest version of Ghost.

  • What’s your URL? Currently the site isn’t hosted but let me know what information I haven’t provided that you might need to troubleshoot
  • What version of Ghost are you using? I’m using Ghost 3.21.1

And

  • How was Ghost installed and configured?
    Ghost is installed locally for theme development
  • What Node version, database, OS & browser are you using?
    Node v10.17.0
    database: squlite3 3.24.0
    OSX Mojave 10.14.6
    browser: Chrome 84.0.4147.105
  • What errors or information do you see in the console?
    I’m getting 404 errors when trying to see posts in the collection I tried making
  • What steps could someone else take to reproduce the issue you’re having?
    I’m going to answer this question long form to show you what I’ve been doing and the trouble I’ve been running into

I tried making a collection of posts all tagged “programs”. There are only 7 posts saved at the moment and they all have this tag. This is my routes.yaml file:

routes:
  /: 
    data: page.howdy
    template: home


collections:
  /programs/:
    permalink: /programs/{slug}/
    filter: tag:programs
    template: page

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

Issue 1: while I can see the cards for the posts with the tag “programs” on the Programs page it is only through a {{#get}} call on that page and hovering over the cards shows that they are linked to “localhost:2369/p/[UUID]” and clicking on any of the cards redirects from the link shown on hover to a 404 page. Additionally querying the db through Postman shows me that all of these posts have the url attribute in the db set to “http://localhost:2369/404

Issue 2: The home page is successfully loading my home.hbs template, but it is not getting the data from the page in the CMS called “Howdy”. “Howdy” however is loading on http://localhost:2369/home
https://ghost.org/tutorials/custom-home-page/ this is the tutorial I tried following to create the custom home page however as I have a default.hbs that is loading my header and footer my home.hbs file looks a little different:

{{!< default}}
{{!-- Main --}}

<div class="gh-article home {{post_class}}">
    <h1 class="gh-title">THIS IS HOME</h1>
    {{#post}}
        <div class="gh-content gh-canvas">
            {{content}}
        </div>
    {{/post}}
</div>

I can’t see a reason why this would work from what you’ve shared.

Can you please update and reconfirm on the latest version?

Also how are you changing the routes.yaml? If you’re editing it directly, are you sure you restarted Ghost afterwards?

The only thing I can see that is weird is that you’re using a template called page.hbs, usually used as the default to render a single page, as a listing template for your collection. I don’t think that would cause this problem but I’ve not tested it to know for sure - it might be worth renaming it to programs.hbs or using the standard index.hbs just until you’ve got everything else ironed out.

I was editing it directly and I think the problem was that I wasn’t restarting the server after uploading the new theme zip.

To be honest I’m a little glad that I’m not going crazy cause I thought it should work, the template specification is definitely weird and it’s like that cause I was trying to figure out if there was a problem with my custom post.hbs but turns out there’s not and I just forgot to restart the server :joy: