I’m trying to do some customization of my theme. I got the home page to look exactly the way I want by taking {{{body}}} out of default.hbs and hard-coding the posts pull. All good.
Then, I realized that the individual posts also use default.hbs, so of course whenever a reader clicks a title link on the home page it merely loads the home page again. (Doh!)
So, I’m thinking of taking the current default.hbs (the one that works for the posts as well as the home page) and making it into a custom template, which of course means I would have to go back through all the posts and reassign them.
A long story to get to the question: What, exactly, does {{{body}}} do? And, how does it both load the home page AND the individual posts? I’m used to one file for a home page and another for the posts, so I’m a little confused. I can’t figure out the execution flow, or how to address this problem gracefully. Thanks!
The {{{body}}}
helper is a special version of the block helper. It basically serves as the placeholder for the the content from your other templates. In short, if you delete it, you’re going to have a bad time.
What I would do is create a new template, home.hbs
, and copy your custom home page markup there. Ghost will automatically load home.hbs
as a custom homepage. I use this setup on my Smart theme, if you want to see an example of how it works.
There’s a lot more that could be said, so let me know if you have other questions.
Thank you so much! I was unaware of the possibility of using home.hbs
as a separate home page. So, I’ve done just what you said, and it is doing what I want.
One question: Do I need to change and upload the routes.yaml? It currently says
collections:
/:
permalink: /{slug}/
template: index
Do I need to change the template setting to template: home
?
Ghost will automatically load home.hbs
for the root path, so you shouldn’t need to change your routes.yaml file. By default, you’ll have access to what you normally would on an index file: your loop of latest posts.