The discussion Add Text In Header Beside Logo revolves around adding custom text beside the logo in the header of a Discourse page. dfuentes initiated the conversation, seeking help to add the text “Community Forums” beside the logo.
Johani provided a script to achieve this, but Jonathan5 pointed out that it no longer works due to changes in Discourse. Lilly suggested using the home-logo plugin outlet connectors as specified in the Discourse documentation.
nolo shared a working solution by creating a glimmer component in components/header-logo-title.gjs and attaching it to the outlet in /api-initializers/my-theme.js. Arkshine provided an alternative approach using api.renderAfterWrapperOutlet("home-logo").
Later, nolo updated the solution and provided a link to a gitlab component that can be used to add custom text beside the logo. James_Cribbs sought help in accessing the glimmer component, and nolo offered alternative solutions.
I’m new to discourse, so I apologize if this is something that is easily done, however, I can’t seem to find where I can define the text that I want to appear beside our logo in the header of our discourse page.
Within the red box in the header is where I’d ideally like to add text saying ‘Community Forums’ or something of the sort:
This is now causing an error banner to be shown, because of changes to Discourse. Do you have any suggestions for achieving the same result with the new approach? Thanks.
Yea that method will no longer work and you need to use the connectors specified here in the section about the home-logo plugin outlet replacing home-logo:after widget decorations:
I just did this for a theme. I’m using the site’s title and short description, but you could also insert values from theme settings or localized text.
Add a glimmer component in components/header-logo-title.gjs
import Component from "@glimmer/component";
import { service } from "@ember/service";
export default class HeaderLogoTitle extends Component {
@service siteSettings;
<template>
{{#unless @outletArgs.minimized}}
<div class="header-logo-title">
<span
class="header-logo-title__title"
>{{this.siteSettings.title}}</span>
{{#if this.siteSettings.short_site_description}}
<span
class="header-logo-title__description"
>{{this.siteSettings.short_site_description}}</span>
{{/if}}
</div>
{{/unless}}
</template>
}
Attach it to the outlet in /api-initializers/my-theme.js
import { apiInitializer } from "discourse/lib/api";
import HeaderLogoTitle from "../components/header-logo-title";
export default apiInitializer("1.26.0", (api) => {
api.renderAfterWrapperOutlet("home-logo", HeaderLogoTitle);
});
The #unless-helper checks for minimized state of the logo and only adds the text when the full logo would be visible. If you always want to show it you’d need to drop that condition.
You can also use api.renderAfterWrapperOutlet("home-logo") (since v.1.26.0). It has the advantage you use the actual outlet name without providing the magic __before/__after.
I had wrapped this in a component, you could try using it: Manuel Kostka / Discourse / Helpers / Header Logo Title · GitLab. It adds the site title and short site description by default. Alternatively, you can add custom text for the title and the description on the component settings.