Add HTML above

AI-generated summary

The discussion is about adding HTML above the categories/posts area on the home page. good_guy is looking for a way to do this and th21 suggests using a plugin outlet. NateDhaliwal provides an example of how to use the before-topic-list outlet with a script tag and Handlebars template.

However, good_guy has trouble getting it to work and NateDhaliwal clarifies that the text/x-handlebars type is required and the component name should be included. good_guy is looking to add the HTML above everything but not above the navbar on all pages and NateDhaliwal suggests using the above-main-container outlet.

After some back and forth, NateDhaliwal reiterates the importance of using the correct text/x-handlebars type and including the component name. Meanwhile, merefield introduces the Discourse Developer Toolbar as a potentially useful tool.


Is there any way I can add HTML above this area (home page above categories/posts)?

I think yes

we have plugin outlet available here

You could do something like this:

<script type="text/x-handlebars" data-template-name="/connectors/before-topic-list/NameOfThing">
  <div class="className">
    <p>Hi there!</p>
  </div>
</script>

This renders the text in the before-topic-list outlet.
You can change the outlet and component names in data-template-name.

Be sure to put this in Customize > CSS > New component > Edit CSS/HTML > Head.

Hey, that didn’t work, nothing appeared, could you double check the code? Is NameOfThing supposed to be there?

Sorry, it’s supposed to be text/x-handlebars instead. I have edited my post.

Yes, that is the name of the component. You can change it to anything you want.

Also, you may want to use the above-main-containter outlet.

What’s the directory for above-main-containter, does it go in type or data-template-name?

I’m specifically looking to make it above everything but not above the navbar (for all pages)

Just replace before-topic-list with above-main-container. It would be below the header.
The above-main-container outlet will display on all pages.
Also, I made a typo: container not containter.

<script type="x-handlebars" data-template-name="/connectors/above-main-container">
    <p>Hi there!</p>
</script>

With and without NameOfThing it doesn’t show still, I am placing it in Head

It seems that you are using x-handlebars, but

It also must have the component name after the outlet, or it will not work.

You can use this now:

(Just to add, thank you to @RGJ for creating and supporting that component for so long, it has been very useful :folded_hands:)