Skip to content

40%off everything for Black Friday, with code . Until Dec 1.

Bright Themes

How to build a custom homepage in Ghost

Turn a page you write in the Ghost editor into your homepage, with one change to routes.yaml and no theme code, and move your posts to /blog/.

Norbert2 min read

Most Ghost themes use the homepage to list your latest posts. If you want a landing page instead, with an introduction, a few sections and calls to action, you can build it in the Ghost editor as a normal page and tell Ghost to show that page at /. Your posts move to /blog/.

Two ways to get a custom homepage

  • A custom template. Write a home.hbs file in your theme with your own HTML and CSS. Ghost uses home.hbs for / automatically. You get full control of the layout, but you need to code, and every change to the homepage is a change to the theme.
  • A page and page.hbs. Build the homepage in the editor and render it with the theme’s page template. No theme code, and you can edit it any time like any other page. The layout is limited to what the editor cards and your theme’s page template can do.

This tutorial covers the second way.

What you need

  • A theme with a page.hbs template. Most themes have one, and all of ours do. Without it, Ghost uses post.hbs, which also works but shows post details such as the date.
  • Access to Settings › Advanced › Labs › Beta features in Ghost Admin, to edit routes.yaml.

1. Create the page

  1. In Ghost Admin, open Pages and choose New page.
  2. Give it a title, such as “Home”.
  3. Open the page settings and set Page URL to home. It must match the slug you use in routes.yaml in the next step.
  4. Write the content and publish the page.

Use editor cards to build the sections: images, buttons, call to action, sign-up, product, embeds and more.

2. Point the homepage to the page

Settings › Advanced › Labs › Beta features

In Settings › Advanced › Labs › Beta features, choose Edit in the Routes row. The editor opens your current routes.yaml, so you keep any routes you already have. Change it so that / uses the page, and the post list moves to /blog/:

YAML
routes:
  /:
    template: page
    data: page.home

collections:
  /blog/:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

What this does:

  • / is rendered with your theme’s page.hbs template.
  • data: page.home loads the content of the page with the slug home. Ghost also redirects the page’s own URL, /home/, to /, so the content doesn’t exist twice.
  • The collection now lives at /blog/, so your list of posts is still there. With permalink: /{slug}/ the posts keep their current URLs. Use permalink: /blog/{slug}/ if you’d rather have them under /blog/, and redirect the old URLs.

Note

The format is resource.slug: page.home, not home. Ghost rejects a data value without the page. part when you save the file.

3. Save routes.yaml

Choose Save in the editor. If you’d rather edit it in a code editor, use Download file and Upload file from the menu in the Routes row instead. Ghost applies the change straight away, with no restart.

Then add a Blog link to /blog/ in Settings › Site › Navigation, so readers can still find your posts.

The result

Your homepage now shows the page you wrote in the editor, and your posts are at /blog/. To change the homepage, edit the home page and update it: no theme upload, no code.

For more on what routes.yaml can do, read how routing works in Ghost. For other ways to give a page its own layout, see custom pages in Ghost.

Related posts

More on templates

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.