# Post Order on tag/{slug} page

**URL:** <https://forum.ghost.org/t/post-order-on-tag-slug-page/33242>\
**Category:** Themes\
**Created:** [October 5, 2022, 6:11pm UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242 "2022-10-05T18:11:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/isaac-tait/32/17977_2.png) [@Isaac-Tait](https://forum.ghost.org/u/Isaac-Tait)\
**Post date:** [October 5, 2022, 6:11pm UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/1 "2022-10-05T18:11:35Z")

</div>

I would like to display my posts in order from oldest to newest. I found [this](https://ghost.org/tutorials/change-post-order/#reversing-the-order) Ghost tutorial. However, it is not working. I think it is because I am trying to order posts on the `tag/{slug}` page. When I add the following line to the `taxonomies` section of the `routes.yaml` file - `order: published_at asc` and then I upload to Ghost Admin \> Labs I get an error message that says:

`The following definition "order" is invalid: Unknown taxonomy.`

* * *

I also tried this in my `tag-part-one.hbs` file without any luck:

```auto
{{!< default}}

<div class="page-width">
    {{#tag}}
        <div>
            <h1>{{ name }}</h1>
        </div>
    {{/tag}}

    <div class="posts">
        {{#foreach posts filter="published_at asc"}}
            <a href="{{url absolute="true"}}">
                {{title}}
            </a>
        {{/foreach}}
    </div>
</div>

```

* * *

I found [this](https://forum.ghost.org/t/post-ordering-at-tags-pages/15054) post, which I think the author is asking the same thing as me but there was no reply. So, I am trying with my own post.

How should I go about ordering posts on my `tag/{slug}` page?

---

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/isaac-tait/32/17977_2.png) [@Isaac-Tait](https://forum.ghost.org/u/Isaac-Tait)\
**Post date:** [October 7, 2022, 2:21pm UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/2 "2022-10-07T14:21:44Z")

</div>

It is a bit hacky but I ended up just tweaking the publish dates of the posts to get them in the order I needed…

---

<div class="post-metadata">

**Author:** ![Ronan\_Keane](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ronan_keane/32/37111_2.png) [@Ronan\_Keane](https://forum.ghost.org/u/Ronan_Keane)\
**Post date:** [September 21, 2025, 7:55am UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/3 "2025-09-21T07:55:06Z")

</div>

Can anyone help with doing this properly?

There is no #get posts in the tags.hbs file.

So it must be passed into the context from somewhere else.

But I can’t see anything in the default or index or any other .hbs file as to how this is done.

I want to order by slug (I mark the slugs a,b,c,d etc.). No problem doing i the home page, i.e. index.hbs file.

But what is going on with the tabs page?

Thanks.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [September 21, 2025, 11:26am UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/4 "2025-09-21T11:26:55Z")

</div>

(Tags.hbs is not a general Ghost file, although some themes provide one. But since you refer to `#get posts`, I’m guessing you mean tag.hbs? Please update if not.)

The tag.hbs page receives the tag data and posts with that tag, as part of its context. They’re just there, because its a tag page.

Unfortunately, taxonomies don’t take an order parameter.

Two workarounds:

Option A: ignore the posts included and get your own, still using tag.hbs. Here’s a basic example that can be adapted to your theme.

```auto
{{#tag}}
{{!-- header stuff for the tag here--}}
{{/tag}}
{{#get "posts" filter="tag:{{tag.slug}}" order="slug asc" page=pagination.page limit=@config.posts_per_page as |myposts|}}

        {{#foreach myposts}}
            {{> "post-card"}} {{!-- adjust for your theme --}}
        {{/foreach}}
{{/get}}

{{pagination}}

```

\*\*Update: fixed an error in the code above. \*\*

That should work because you have the same number of posts with the tag, so the pagination helper can still help paginate the posts, event though you’re not displaying the ones it expects

Option B. Use a channel. Channels paginate and are non-exclusive, so you can use one to collect all posts with a specific tag. (If you’ve ever wanted multiple tags on a tag page, this is a good way, too.)

In your routes.yaml (uploaded in /ghost \> settings \> labs)

```auto
routes:
  /yourtag/:
    template: tag
    order: slug asc
    controller: channel
    filter: tags:[yourtag]
    data: tag.yourtag

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

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

```

(Collections and taxonomies shown for completeness. If you already have a customized routes file, you’d want to add the bit under routes to it.)

If you only need to sort the posts of a couple of tags, you could make a routes entry like this for each one. If you need to sort posts for dozens and dozens of tags, then I think option A is definitely better, because this would be a lot of work!

---

<div class="post-metadata">

**Author:** ![Ronan\_Keane](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ronan_keane/32/37111_2.png) [@Ronan\_Keane](https://forum.ghost.org/u/Ronan_Keane)\
**Post date:** [September 22, 2025, 7:50am UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/5 "2025-09-22T07:50:28Z")

</div>

That worked perfectly in my tag.hbs file. Problem solved. Thank you so much.

---

<div class="post-metadata">

**Author:** ![Ronan\_Keane](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ronan_keane/32/37111_2.png) [@Ronan\_Keane](https://forum.ghost.org/u/Ronan_Keane)\
**Post date:** [September 22, 2025, 7:56am UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/6 "2025-09-22T07:56:37Z")

</div>

Just out of interest, how was the #get posts list being passed into the context of the tag.hbs page in its unedited default state?

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [September 22, 2025, 11:21am UTC](https://forum.ghost.org/t/post-order-on-tag-slug-page/33242/7 "2025-09-22T11:21:36Z")

</div>

Ghost provides appropriate context (i.e. the tag name, image, and description, and the (first page of) posts with that tag) to the tag.hbs template. You can read more here, if interested!

> **[Contexts - Ghost Developer Docs](https://docs.ghost.org/themes/contexts)**
>
> Each page in a Ghost theme belongs to a context, which determines which template is used, what data will be available and what content is output by the \`{{body\_class}}\` helper.
