Ghost Handlebars Overview


Handlebars is a templating language that Ghost uses to make the ability go grab content from the database very easy. Handlebars is characterized by curly braces ex. {{content}}. When you are creating or editing a theme, you will find that these Handlebars templates can save you a lot of time.

Like we stated in the Ghost theming overview, the biggest problem we see people having with handlebars is really just not knowing what it is and getting discouraged. You can build an entire theme not using Handlebars at all if you would like, since Ghost themes are just normal HTML. Handlebars are additions you can use to help customize your site to work better with Ghost. For example, for a header, instead of just statically butting in the title of your blog, you can use this:

<h1>{{@blog.title}}</h1>

That way, if you change your blog title from the Ghost setting screen, it will change on your theme without you needing to do any code changes.

The Ghost team has put together some amazing documentation around each Handlebars helper that I am not going to try and replicate because it would be almost identical and it is always changing. Check out the link below for all of the Handlebars helpers, how each of them are used, and examples of code.

Theme Documentation