# Templates for posts in a collection

**URL:** <https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466>\
**Category:** Themes\
**Created:** [June 14, 2021, 12:27am UTC](https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466 "2021-06-14T00:27:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolmoods](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/coolmoods/32/13408_2.png) [@coolmoods](https://forum.ghost.org/u/coolmoods)\
**Post date:** [June 14, 2021, 12:27am UTC](https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466/1 "2021-06-14T00:27:30Z")

</div>

I created a collection in my routes.yaml file so I can have posts show up with the primary tag in the URL, like so:

**routes.yml**

```auto
collections:
  /favorites/:
    permalink: /favorites/{slug}/
    template: favorites
    filter: primary_tag:favorites

```

**Results**

- `/favorites` uses the **favorites.hbs** template
- `/favorites/{slug}` uses the **post.hbs** template

I can’t figure out how to get the individual posts to use a template other than **post.hbs**. Seems like **tag-favorites.hbs** should do the trick, but everything under `/favorites/{slug}` is still loading post.hbs (and yes, I restarted Ghost). Any tips on how to achieve this?

---

<div class="post-metadata">

**Author:** ![brightthemes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/brightthemes/32/42205_2.png) [@brightthemes](https://forum.ghost.org/u/brightthemes)\
**Post date:** [June 16, 2021, 12:35pm UTC](https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466/2 "2021-06-16T12:35:49Z")

</div>

Hi @coolmoods,

It seems you are looking to create custom post templates.

> **[Create a custom post template in Ghost](https://ghost.org/tutorials/create-a-custom-post-template/)**
>
> In this tutorial, learn how to create a custom template to give your posts a distinctive look.

After you created a custom template you can assign it to any post in the Admin:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/0/0601a79323cff5e5a0a49b4e80af6b2e9a27be7c.png)

---

<div class="post-metadata">

**Author:** ![coolmoods](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/coolmoods/32/13408_2.png) [@coolmoods](https://forum.ghost.org/u/coolmoods)\
**Post date:** [June 16, 2021, 8:10pm UTC](https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466/3 "2021-06-16T20:10:58Z")

</div>

Ah, OK. I was hoping I wouldn’t have to make the editors manually choose a template (more room for goofs), but it’s good to know it’s an option.

---

<div class="post-metadata">

**Author:** ![lukecyca](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lukecyca/32/12028_2.png) [@lukecyca](https://forum.ghost.org/u/lukecyca)\
**Post date:** [October 19, 2021, 4:58am UTC](https://forum.ghost.org/t/templates-for-posts-in-a-collection/23466/4 "2021-10-19T04:58:16Z")

</div>

I found a viable workaround:

1. Create your various post templates in the `partials` subdirectory.

2. Edit your main `post.hbs` to include the correct template based on tag criteria:

```auto
{{!< default}}

{{#post}}
  {{#has tag="newsletter"}}
    {{> post-newsletter ..}}
  {{else has tag="podcast"}}
    {{> post-podcast ..}}
  {{else}}
    {{> post-generic ..}}
  {{/has}}
{{/post}}

```
