Can you create a "Channel" template?

I want to create a channel for my posts. The problem is that I can’t seem to set a template for it. Is it even possible?

At the moment my channel uses the deafult.hbs template file.

Hey there. Could you explain what you mean by a “channel”? Is there an example you can provide?

This is what I mean:

Assuming you are referring to the dynamic routing channels then you can specify the template that should be used for the index pages. Eg:

routes:
  /apple-news/:
    controller: channel
    filter: tag:[iphone,ipad,mac]
    template: collection-apple-news

^ would use your-theme/collection-apple-news.hbs when rendering index pages.

The fallback heirarchy for a collection index template is: template specified routes.yaml -> index.hbs -> default.hbs.

For the posts themselves, there’s no way to set the template for all of the posts in a channel via routes.yaml because posts can appear in multiple channels. If you wanted them to have their own template then you’d need to either use tags and the {{#has}} helper to pick a particular partial or use the custom-{{template-name}}.hbs feature where you can pick a particular template from a dropdown for each of the posts you want to display differently.

2 Likes

Got it! Thanks for the great answer.
I did try adding a template before but it didn’t work. Must have been user error.

2 Likes