在 Ghost 上创建自定义页面

Create custom pages on Ghost

我希望向 ghost/custom/themes/casper 添加更多 .hbs 文件,例如关于页面和登录页面。这样,所有文件都使用相同的默认布局,我的博客有一个 /blog 目标。

但是,当我创建一个 .hbs 文件时,例如 about.hbs,并为其提供与 page.hbs 中相同的代码,并将其上传到主题文件夹,当我转到我的-url.com/about,它给出了 404.

那么,如何创建自定义 .hbs 页面?

  1. 在 Ghost 后端创建带有特定 slug 的页面。
  2. 创建这样命名的 .hbs 文件:page-about.hbs

来自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.