Handlebars template override all in the same html file?

AI-generated summary

In a discussion about overriding Handlebars templates in Discourse themes, Pieces asks whether it’s possible to organize multiple template overrides in separate .hbr files within a templates folder, rather than cramming all script tags into header.html, which they find unmaintainable. merefield responds by linking to a meta post that advises against overriding core templates from themes or plugins, noting that such practices are not recommended. Pieces agrees the Handlebars section in the Beginners Guide should be revised or removed to clarify this, but still seeks a practical solution for managing multiple overrides. merefield points out the answer is in the expandable section of the linked article, which Pieces acknowledges they missed, adding a smiley emoji. The core takeaway is that while technically possible to override templates via script tags in HTML, it’s discouraged — and the recommended approach is detailed in the linked meta article’s expandable content.

Hello,

I am following the Beginners Guide to Discourse themes guide (this one: Developing Discourse Themes & Theme Components) but I am getting stuck and have some questions about the Handlebars section.

The guide states if you want to override a template you need to add a script tag with location of the template you want to override to your theme, in my local file I added it to header.html.

Is this the only way?

It is not possible to add a hbr file to my theme in a templates folder that overrides the theme template file?

I doesn’t feel maintainable if I want to make multiple template overrides, it will fill up the header.html really fast and make it unmanageable. I am new to Handlebars so I might be missing something.

So my question is, how does one handle mutliple handlebars template overwrites without making it a big mess in 1 of the html files of a custom theme?

Take note:

Thank you, maybe it is a good idea to remove the Handlebars section from the beginners guide or at least rewrite it to make it very clear this is not the recommended approach to make changes to a custom theme.

Still looking for an answer to my question though.

It’s detailed in the linked article in the expandable area.

Thanks Robert, didn’t look at the expandable part… :slight_smile: