Page template throwing 404 error


#1

Hi there,

I haven’t found anyone having a similar problem in this forum or on google, so let me explain.

I created a template for an About page. Followed the documentation to the letter. I have a file in /mytheme/page-about.hbs and I added the About link to the admin panel as http://localhost:2368/about/ (which is generated in {{navigation}} in my template).

When I click on the navlink about it throws a 404 error. Am I missing something here?


#2

You have two options for creating custom pages in Ghost:

1.Dynamic

Dynamic pages would still use content created and managed via the editor.

You have a page-about.hbs template, but for it to be rendered, you need to create and publish a page that has the match about slug. Once that’s done, the page will appear.

  1. Static

Static pages use only a template by default, unless you explicitly wire up data.

For this, you’d need to ad the associated entry in your routes.yaml file.


#3

Thanks for the swift reply Hannah,

I’ve figured both ways out that you linked and they are working. It would be a solution to my problem. Especially the static page that I could link in the routes.yaml.

I am wondering though why this section https://docs.ghost.org/api/handlebars-themes/context/page/#templates is not working for me.

It seems that this solution would be the easiest but my Ghost is not picking up my page-:slug.hbs templates.


#4

Adding a template on it’s own is not enough. The handlebars theme documentation you are linking to is telling you how to create a custom template for a dynamic page, as opposed to just using the page.hbs template. The page has to exist for it to work.