How can I specify a custom post template for a collection post

I’m using latest ghost & cli (2.0.3 & 1.9.1) fresh local install, and using the new amazing dynamic routes somewhat successfully. I’ve managed to get the index page working just fine with a collection, but I’d like the pages within that collection to use a specific template, not the default post.hbs template. Now I know that I can define a custom-${templatename}.hbs template as was standard in 1.0, but I’d rather not have to require that editors have to select the custom layout from the admin side, rather I’d like to suggest a custom default based on the collection (& possible allow them to override). Is this functionality available or not yet?

For reference, here’s my routes.yml

routes:

  /:
    data: post.home
    template: home

collections:
  /showcase/:
    template: collection-showcase
    permalink: /showcase/{slug}/
    filter: tag:showcase

  /:
    permalink: /{slug}/
    template:
    - index
    filter: tag:-[showcase]

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

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

I have exactly the same question. It is a shame this has never been answered. I must assume that the answer is no, you can’t have a custom post template for a collection. You can only have a custom index URL template for the collection. The tutorials really don’t make this clear at all.

OK, I think the way forward is to create a global custom post template and select it when creating the post, as discussed here:

1 Like

I can’t find the option to choose a custom template anywhere in my post settings. I fear they have removed that functionality and haven’t updated the documents. Hopefully someone can prove me wrong?

Edit: I’ve figured out that the Ghost Editor needs to be aware of the existence of custom templates before providing that option, and Ghost requires that you prepend the template filename with custom- to know it’s a custom template. It would be helpful if this were added to the documentation.

I haven’t been able to get this to work for me. I see nothing at all. I used custom- and nothing shows up.

You will need to restart Ghost in order for it to notice the new custom template file.