Inject Widget in custom HTML

When you add raw HTML in the header tab of your theme, it gets added here
discourse/app/views/layouts/application.html.erb at 13b31def80c1f1262bf6fd21226c0639dcfabb13 · discourse/discourse · GitHub

This is outside of the application. So, you can’t use stuff like

{{mount-widget widget="my-dark-light-widget"}}

Instead of adding raw HTML, use the above-site-header plugin-outlet. It’s inserted in the same place, so it should look the same visually.

Something like this

<script type="text/x-handlebars" data-template-name="/connectors/above-site-header/my-sidebar">
  add your HTML here
  You can insert {{mount-widget widget="my-dark-light-widget"}} anywhere in the markup
</script>