Headline - code injection?

Hi friends! I’m using the Headline theme, which has a file related-posts.hbs that puts related posts at the bottom of a post. The default is a limit of 3 and I want to increase that. I know how to do it by downloading the theme, editing and uploading again, but does anyone know if it’s possible to alter this via code injection instead? This is the full code of the file. Thank you!

It’s not possible with code injection because what you want to change is part of the templating system.

By the time code injection has a chance to run, the templating phase is complete and only rendered HTML is left.

Customizing the template is the best way.

Is your concern that you would like to maintain your changes while also receiving updates to the Headline theme?

Yeah, that’s what I thought. Thanks! And yes, it’s so much easier to just let the updates run themselves. But now I suppose I have a reason to try and fix the multiple authors problem…

I also want to maintain changes to the Headline theme while also merging in future changes-- I’d like “dark mode” and also to replace the “Latest” section of the home page with a “Featured” section.

Here’s my plan:

  1. Checkout the “Themes” repo which contains it, using Git: GitHub - TryGhost/Themes: A monorepo for Ghost themes
  2. Create a new branch of the project for my changes in Git, and make my changes there.
  3. As new changes are made to the Headline git repo, I’ll rebase my branch on the main branch, effectively re-playing my changes on top of the upstream changes.
2 Likes