Configure Collection Posts to All Use the Same Template

I thought I had Collections figured out, but apparently there’s one piece I’m missing! I’m trying to configure a locally installed Ghost instance to use:

  1. The site homepage will be the blog, using the template index.hbs
  2. Blog posts will display using post.hbs
  3. Comic posts should NOT display on the homepage, and will use the template comic.hbs (these should display one at a time, full page)
  4. The most recent comic post is the index of the collection - /comic/ and uses the comic.hbs template.

I added a collection for a comic posts, almost identical to the example on Content Collections page (Ghost Themes - Dynamic URLs & Routing):

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tags:-[comic]
  /comic/:
    permalink: /comic/{slug}/
    template: comic
    filter: primary_tag:comic

So far, most things work. I have blog posts on the home page and comic posts don’t show. Clicking through to a blog post goes to the post template (post.hbs). Going to the comic page - /comic/ in the URL - goes to the comic template (comic.hbs) and displays the most recent comic!

What’s broken is how to get all of the OTHER comic posts to also use the comic.hbs template. Currently they use post.hbs.

What did I miss?

Thanks!

To have all of the other comic posts also use the comic.hbs template, I believe you’ll need to rename the file.

So, you’d want to rename it as custom-comic.hbs - this will let Ghost detect a new template file and give it as an option in the settings panel of a post. So then you can set each comic to use this new template in the settings:

I threw this custom-comic.hbs right where all of the other .hbs files are.

In terms of setting all of your posts that belong to your comic collection to use comic.hbs, I could not find anything. I think the routes.yaml templates only apply to the collection display, not the individual posts that belong to that collection. Someone please let me know if this is wrong :slight_smile:

Hope this helps!

3 Likes

Hey @dan.2rational - I’m exploring Ghost for comics too! How did you do? Do you have a link to your site?