Defining your own helpers in Ghost
This blog is run on the Ghost blogging platform. Ghost uses handlebars as a templating engine behind the scenes. With a standard Ghost installation come many useful handlebars helpers such as url
or foreach
.
Since I needed to write my own helpers to accomplish things that weren’t offered by Ghost out of the box I looked around for tutorials on how to do that.
None of them seemed to work. The only thing that proved successful was going into the helpers directory and adding your custom helpers to those already offered by Ghost.
Here is how you do that:
- Go into core/server/helpers and add your own helper.
- Open index.js that resides in core/server/helpers and register your newly added helper the way all the other helpers are registered too.
Pretty simple and straightforward.