Adding partials to a theme - how to?

Running latest ghost and Starter theme, new to ghost theme development (but experienced front end developer)

I looked but didn’t find, how do I add partials to my theme?

According to the handlbars documentation at Partials | Handlebars

I have to make a call to registerPartial. But where would this go?

Is there something else I am missing?

Thanks for your assistance!

Check out Ghost Handlebars Theme Helpers: partials

Two tips, to go with Vikas’ great link:

  1. Ghost’s version of handlebars is not the same as the handlebars documentation. You’re almost always going to be better off with the Ghost documentation.

  2. When you add a new .hbs file, you’ll need to restart Ghost to get it recognized. (Not the case if uploading a whole theme zip file, but you’re probably not doing that in development… and if you are, I highly recommend that you switch over to local development so that you can edit the files and see changes immediately! Worth the time, if you’re going to develop a whole theme, for sure!)

So just to be clear, all partials in the /partials directory are automatically available to the main template?

I’ll try that tomorrow. I thought I already did, but maybe I didn’t restart ghost. It makes sense I’ll have to in order to automatically pick them up.

Thanks again!

1 Like

Correct. Put them in the partials folder, with a ,hbs extension. :slight_smile:

Then you call them like {{> your-partial }}

Thanks, got it! It works!

@vikaspotluri123 thanks to you too!

1 Like