Routes.yaml not detecting static route

I’m trying to make a page that lists out all tags (preferably those with posts) inside a new url.
This will be at domain.com/tags/

My routes.yaml is at follows:

routes:
  /signup/: members/signup
  /signin/: members/signin
  /account/: members/account
  /tags/: tags

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

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

This should (theoratically) load in tags.hbs file which I have in the theme’s root folder beside routes.yaml.

My tags.hbs file is as follows:

{{!< default}}

<header class="site-header">
    <div class="outer site-nav-main">
        <div class="inner">
            {{> "site-nav"}}
        </div>
    </div>
</header>

<main id="site-main" class="site-main outer" role="main">
    <div class="inner">
        <header class="post-full-header">
            <h1 class="post-full-title">{{ title }}</h1>
        </header>
        {{#get "tags" limit="all"}}
        {{#foreach tags}}

        <a href="{{ url }}">
            <h2>
                {{ name }} <small>({{ count.posts }})</small>
            </h2>
        </a>
        {{/foreach}}
        {{/get}}
    </div>
</main>

This allows me to get all the tags, I think. After zipping the theme up and uploading via the admin interface however, I’m greeted with a 404 page not found when navigating to domain.com/tags/.

Note that I do not have a self-created page called Tags with the url /tags/ through the pages tab in the admin interface.

Any help would be appreciated! Thank you!

What version of Ghost are you running? What server or environment are you running?

The topic template includes all of these questions because the information is key to helping resolve most issues.

Sorry for leaving those out! I’m running Ghost version 3.7.0. It’s being hosted on a DigitalOcean Ubuntu droplet, and is containerized in a Docker container.

Cool - latest version is 3.13.4 - so updating is always a good first step.

Are you editing content/settings/routes.yaml directly, or uploading it via Ghost Admin / Labs UI?

I’m not looking to update at the moment, as I’m still in the process of backing up the files before updating. Would love if there was some other method to solve this as this doesn’t seem like a problem with the version of Ghost.

I’m not sure what you mean by content/settings/routes.yaml. I downloading the theme files off the Ghost Admin panel (I’m using Lyra) and edited the routes.yaml found in the theme folder. After editing, I uploading the new zip back onto the site using the Ghost Admin panel again.

Routes are not part of themes, they are uploaded separately either in Ghost Admin under “Labs” - or directly in /content/settings/routes.yaml

Some people keep them in theme directories for convenience when working with Git.

Documentation for routes is here:

2 Likes

Oh wow, can’t believe I missed that even thought I read that whole thing before haha. Thanks for the help!

1 Like

No problem! Glad you got it working