Product Dev Back to Ghost

Creating a custom page template on Ghost

If you need to have a more specific look for your page content, you can easily create a page template within your theme by following the guide below.

Log in to your Ghost blog

First, log in to your ghost blog with your admin user credentials.

Create a static page

If you plan to have your contact form on a "Contact" page, you'll need to first create a static page on your blog to house the form. To do this,

  • Click on "New Post" from the top of your admin navigation menu
  • Provide a title for your page
  • Edit the post settings of your page by clicking on the "gear" icon next to the "Save draft" button and check "Static page"
  • Publish your static page

Make a note of what your static page's URL is. For example, if my contact page is called "Contact Me," the page URL would be /contact-me/. You will need to use this page URL in a later step.

Note:Need help creating a static page? Checkout our guide on How to publish a static page for step-by-step instruction.

Create a custom page template

Now that we've created a static page, we'll need to create a custom page template inside our theme. To do this, first create a new file within your theme's root directory. Page templates must always start out with 'page-' and then include the page URL after the hyphen. So, for example: If you have an about page with a page URL of "About" your page template name would be "page-about.hbs"

Create page template

Copy the code from your page.hbs file

Once you've created your page template you'll need add some code to it. Copy the code from your theme's page.hbs file and paste it into your new page template. When you're finished, save the page template file.

Copy page code

Modify your page template code as neccessary

Once you've finished pasting over the code from the page.hbs file into your new page template file, you can customise anything about it. The changes made to your custom page template will be reflected on the new static page it belongs to.