# Inject html only on one page

**URL:** https://meta.discourse.org/t/inject-html-only-on-one-page/409186
**Category:** Development
**Created:** [August 3, 2026, 7:11pm UTC](https://meta.discourse.org/t/inject-html-only-on-one-page/409186 "2026-08-03T19:11:57Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [August 3, 2026, 7:31pm UTC](https://meta.discourse.org/t/inject-html-only-on-one-page/409186/2 "2026-08-03T19:31:02Z")

</div>

It’s a good question, don’t worry about it! This will work:

```gjs
import Component from "@glimmer/component";
import { service } from "@ember/service";
import { apiInitializer } from "discourse/lib/api";
import { defaultHomepage } from "discourse/lib/utilities";

class HomepageOnly extends Component {
  @service router;

  get shouldShow() {
    return this.router.currentRouteName === `discovery.${defaultHomepage()}`;
  }

  <template>
    {{#if this.shouldShow}}
      <div>
        html stuff
      </div>
    {{/if}}
  </template>
}

export default apiInitializer((api) => {
  api.renderInOutlet("above-main-container", HomepageOnly);
});

```

This creates a new component, which uses the `router` service and `defaultHomepage` utility to check if you’re on the homepage. Then the component is rendered in the outlet.

There’s a little more here: [Add custom content that only appears on your homepage](https://meta.discourse.org/t/add-custom-content-that-only-appears-on-your-homepage/131415)

---

_[View the full topic](https://meta.discourse.org/t/inject-html-only-on-one-page/409186)._
