Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom pages on Ghost

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?

like image 379
Griffin Avatar asked Dec 18 '22 15:12

Griffin


1 Answers

  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.

like image 56
Reedyn Avatar answered Jan 05 '23 11:01

Reedyn