Griffin
Griffin

Reputation: 842

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?

Upvotes: 4

Views: 4030

Answers (1)

Reedyn
Reedyn

Reputation: 321

  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.

Upvotes: 11

Related Questions