4

I'm looking to add some more .hbs files to ghost/custom/themes/casper, such as an about page and landing page. This way, all files are using the same default layout and I have a /blog destination for my blog.

However, when I create an .hbs file, such as about.hbs, and give it the same code as in page.hbs, and upload it to the theme folder, when I go to my-url.com/about, it gives a 404.

So, how can I create custom .hbs pages?

Griffin
  • 710
  • 2
  • 15
  • 29

1 Answers1

11
  1. Create the page with the specific slug in the Ghost backend.
  2. Create the .hbs-file named like this: page-about.hbs.

From Ghost Documentation on custom pages:

For example, if you have an 'About' page with the url /about/, adding a template called page-about.hbs will cause that template to be used for the about page, instead of page.hbs, or post.hbs.

These templates exist in a hierarchy. Ghost looks for a template which matches the slug (page-:slug.hbs) first, then looks for page.hbs and finally uses post.hbs if neither is available.

Reedyn
  • 321
  • 2
  • 8
  • So I've created and uploaded a file `page-about.hbs`. I then did a `service ghost restart`, restarting Ghost. However I still a 404 error when visiting my-ip/about. – Griffin Jul 01 '16 at 16:59
  • Did you delete the old `about.hbs`-file? – Reedyn Jul 01 '16 at 18:58
  • Yes. All the default files are there as well as the `page-about.hbs` file. – Griffin Jul 01 '16 at 21:21
  • The only things left to troubleshoot is if you are running a fairly recent version of Ghost and that you have actually created the page with that slug in the admin GUI. – Reedyn Jul 01 '16 at 22:47
  • 3
    Ah, creating the page was the solution. Thanks you so much! – Griffin Jul 05 '16 at 19:38
  • Thank you. I'm glad I could be of help :) – Reedyn Jul 05 '16 at 19:39
  • I have created page-signup.hbs and added the route in yml ``` routes: /signup/: template: signup``` .. but getting redirected to http://localhost:2368/ghost/#/signup/ – Yuvaraj V Feb 06 '19 at 02:45
  • My best guess is that either the page isn't created through the GUI or it could be that `/signup` is reserved for Ghost Core. – Reedyn Feb 07 '19 at 07:18