Ghost: Custom post template - Inconsistent documentation and not working if implemented

Issue Summary

This section of documentation states that Ghost supports custom post templates if you create a post-{{slug}}.hbs theme file:

http://themes.ghost.org/docs/templates

However, this same page then refers you to this link for more information: post-context

This page states:

The post context always uses the post.hbs template. This template is required in all Ghost themes. At present there is no support for custom post templates as there is for pages.

So I’m confused as to whether this is currently supported or not?

Steps to Reproduce

  1. I currently have a post titled “Test” with a post-slug of test.
  2. I adapted post.hbs to include a couple of extra scripts in the page
  3. I published the page

When I inspect the html for the page, it is clear that the default post template is still being used. info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

This feature doesn’t need the Public API to be enabled and it does work in both 0.11.4 and the latest master. I’ve tested out both just now.

You do need to restart Ghost when adding new templates via the file system though - not sure if that’s what’s tripping folks up here.

Interesting. New to ghost but just hit this same issue which required a restart.

Version 2.25.4 Environment development Database sqlite3 Mail Direct

After ghost install local In casper theme did a yarn install and yarn dev

Added a page-test.hbs in Casper which compiled into the “current” directory. Other theme changes did appear to work correctly but this did not. It appeared to continue to just use page.hbs

Did a ghost restart local and boom the page-test.hbs started working. fwiw

Do the post-{{slug}}.hbs files live in the root of the theme or in the partials directory?

In the root folder. Please double check that you are editing the correct theme.

Please open a forum topic to get further help. We can re-open this issue if there is a bug in Ghost.

Hi @kirrg001

Thank you for responding.

I’ve also realised that I can create a template that appears in a drop-down in the admin settings. Which does the same thing.

But I will also persevere with getting the post-{{slug}} to work as well.

Thanks again

@kaelifa This works fine for me. I have added a post with the slug “test” and added a post-test.hbs file in my active theme. The post renders automatically with my new template. Please restart your blog if your blog is running in production mode.

Please use our forum for further help. Thanks!