Templates and layouts

Templates

A template is the design of one kind of page on your Ghost site, such as a post, a tag archive or the front page. Every project starts with six built-in templates, and you add more for one post, a tag, a collection or an error page. Click the page icon at the top of the icon rail, Templates, to list them. Click a template to open it on the canvas and its settings in the right sidebar.

The Templates list with Homepage, Collections, Post, Page, Tag and Author and added templates under them, beside the Post template on the canvas

Built-in templates

These six are in every project and cannot be removed. Each starts with the sections listed.

Template

File

What Ghost shows with it

Sections it starts with

Homepage

home.hbs

The front page of your site, at /

Featured Posts, Newsletter CTA, Latest Posts

Collections

index.hbs

The next pages of your post list, /page/2/ and on, or the whole list when you give it its own Path

Posts

Post

post.hbs

Every post that no other template matches

Post Header, Featured Media, Post Content, Post Comments, Related Posts

Page

page.hbs

Every page that no other template matches

Page Header, Featured Media, Post Content

Tag

tag.hbs

The list of a tag's posts, such as /tag/travel/

Tag Header, Featured Media, Tag Posts

Author

author.hbs

The list of an author's posts, such as /author/sarah/

Author Header, Author Posts

Which template Ghost uses for each page explains which template wins when several match. Your Ghost site gets your templates when you publish your theme or upload it again.

Templates you can add

Click + next to Templates to open the Add Template menu. A template you add appears under the template it is based on, such as /about under Page. Custom templates get their own heading, Custom, and error pages get Error.

Menu item

What it adds

File

Ghost uses it for

Post template

Post for specific slug or Post by tag

post- and the slug, or a file under partials/templates/

One post, or every post with an internal tag

Page template

Page for specific slug or Page by tag

page- and the slug, or a file under partials/templates/

One page, or every page with an internal tag

Collection

Custom collection

The collection's name, such as resources.hbs

A list of posts at its own address

Custom template

A template with the name you enter

custom- and the name

Posts and pages a writer gives it in Ghost

Tag template

Tag for specific Slug

tag- and the slug

One tag's list of posts

Author template

Author for specific Slug

author- and the slug

One author's list of posts

Error pages

Error, 404 Error, 4xx Error or 5xx Error

error.hbs, error-404.hbs, error-4xx.hbs, error-5xx.hbs

Pages that show an error

A new template for a slug, a tag or a custom name starts as a copy of the current Post, Page, Tag or Author template, so it already has your design. A new error page starts with one section, Error Message, which holds a heading, the error message and a Back to home button.

The menu also offers ready-made items. Each one disappears from the menu once your project has it.

  • Recommended pages: About, Contact, Authors, Tags and Recommendations add a Page template for that slug. Contact, Authors, Tags and Recommendations come with their own sections, such as a contact form or a list of all tags. The contact form needs the address of your form service, as Add a contact form explains. About starts as a copy of Page.
  • Recommended collections: Projects, Courses, Writings and News add a collection at that address, with a Post template for its internal tag: #project, #course, #writing and #news.
  • Custom: shows while your project has no custom template. It adds a custom template named Narrow, a post design with narrow text and no sidebar.

Template settings

Select a template in the list, and the Template tab of the right sidebar shows its settings. The first line says when Ghost uses the template. The fields depend on the kind of template.

Setting

Shows for

What it does

Slug

Templates for one post, page, tag or author

The Ghost slug the template is for, such as about.

Internal tag

Templates for a tag

The internal tag the template is for, such as #review.

Template name

Custom templates

The name, which also sets the file name, such as custom-longform.hbs.

Path

Collections and collections you add

The address of the post list, such as projects for /projects/.

Post permalink

Collections and collections you add

The address of each post in the list, such as /{slug}/. It must hold {slug} once.

Internal tag

Collections you add

The internal tag, without #, that writers add to a post in Ghost to put it into the collection.

URL slug

Tag and Author

The first part of the address of every tag or author page, tag or author by default.

File

All

The file name in your theme.

Sections

All

How many sections the template has.

Layout

All

The layout that gives the template its header, footer and dialogs. A template for a tag shows the layout of Post or Page instead, and follows it.

A change to Path, Post permalink or URL slug changes your site's addresses, which Ghost reads from a routes file. Upload routes.yaml explains it.

Template menu

Right-click a template in the list to open its menu.

Item

What it does

Open fullscreen

Shows the template alone on the canvas.

Add Post Template… and the other Add items

Opens the form that adds a template under this one. Shows on the built-in template at the top of each group, such as Post.

Layout

Picks the template's layout, or New layout to make an empty one for it. Not shown for a template for a tag.

Delete template

Removes a template you added, with its sections, after you confirm. The six built-in templates cannot be removed.

Limits

A project holds up to 36 templates besides the six built-in ones, of every kind together. Of those, up to 16 can be templates for a tag and up to 16 can be collections. At one of these limits, Fantasma shows a message such as "The project cannot accept more tagged templates."

When the slug, tag or name you enter already has a template, the template is not added, and Fantasma shows Could not create template.

Was this article helpful?