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.
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:
https://ghost.org/docs/api/v2/handlebars-themes/routing/channels/
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.
Got it! Thanks for the great answer.
I did try adding a template before but it didn’t work. Must have been user error.
An how about grouping channels like a “super tag” system?
Let’s say I want to display all my 4 channels (that has each one its specific filters) like I display tag in a proper “tag page” template.
I like the management page tag in the ghost backend and would like channel like a “super tag”.
Is it possible?