The Ghost Themes Developer Hub

Welcome to the Ghost Themes developer hub. You'll find comprehensive guides and documentation to help you start working with Ghost Themes as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Context Overview

An explanation of contexts in Ghost themes

Each page in a Ghost theme belongs to a context. The context can be determined by the URL, and tells you which template will be used, what data will be available to output and what will be output by the {{body_class}} helper.

What is a context?

Each Ghost blog follows a structure: certain URLs, or 'routes' map to views which are intended to display specific data - a list of posts, a single post or an RSS feed. The route determines what data is meant to be shown and what template file gets used to render it.

For example, the page which contains the default first post when you start a Ghost blog lives under the URL /welcome-to-ghost/ and is intended show the content of this post. Ghost will output this page by providing the post.hbs template with all the data for the given post, as well as some global data. This is referred to as the post context - whenever you're viewing a single post via its own URL, you are in the post context.

Whenever you activate a context by visiting a URL, you are guaranteed that you will have access to a particular set of data for that context, and that the page will be rendered using a particular template. Ghost does not provide access to all data in all contexts, instead it optimises the fetching of the data and rendering of the page so that the blog is super fast.

Using contexts in themes

The context is what drives a whole bunch of how themes work. As well as determining what data is available and which template is used to render the page, the context has an impact on several helpers.

The {{body_class}} helper outputs different classes based on the current context.

The {{meta_title}} helper outputs different things based on the current context and whether there is a specific meta_title property available. E.g. when in the post context, the helper knows it can use post.meta_title, and in a tag context it knows it can use tag.meta_title.

If you'd like to detect the current context, for example in a partial template that is shared between many contexts, you can do so using the {{#is}} helper. Pass it a context and it will execute the contained block only when in that context.

Context Table

The table below provides the details of all the different contexts available in Ghost. It shows what the name of the context is, what their URLs or routes will look like, which template they use (in order of precedence), what data they have available to them and what will be output by the {{body_class}} helper.

Body Classes


[{post}], {pagination}



[{post}], {pagination}




.post-template, .tag-:slug






.page-template, .tag-:slug


[{post}], {pagination}, {tag}

.tag-template, .tag-:slug


[{post}], {pagination}, {tag}

.tag-template, .tag-:slug, .paged


[{post}], {pagination}, {author}

.author-template, .author-:slug


[{post}], {pagination}, {author}

.author-template, .author-:slug .paged





Documentation in progress ✨

Context Overview

An explanation of contexts in Ghost themes