# Hoe CSS alleen toepassen op de gewijzigde forum startpagina?

**URL:** https://meta.discourse.org/t/how-to-make-the-css-apply-to-only-the-modified-forum-homepage/267299
**Category:** Development
**Created:** [5 juni 2023 om 19:10 UTC](https://meta.discourse.org/t/how-to-make-the-css-apply-to-only-the-modified-forum-homepage/267299 "2023-06-05T19:10:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [5 juni 2023 om 19:10 UTC](https://meta.discourse.org/t/how-to-make-the-css-apply-to-only-the-modified-forum-homepage/267299/1 "2023-06-05T19:10:17Z")

</div>

I’m making a modification and I want this modification to only work on the HOME, but it’s taking all the pages, how can I leave it only on the home?

i used this

```plaintext
 #main-outlet-wrapper {
    margin-top: -38px;

}

```

---

<div class="post-metadata">

### Author: ![carson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carson/32/280685_2.png) [@carson](https://meta.discourse.org/u/carson)
#### Post date: [5 juni 2023 om 20:11 UTC](https://meta.discourse.org/t/how-to-make-the-css-apply-to-only-the-modified-forum-homepage/267299/2 "2023-06-05T20:11:21Z")

</div>

> [@Add custom content that only appears on your homepage](https://meta.discourse.org/t/add-custom-content-that-only-appears-on-your-homepage/131415):
>
> A very common situation you’ll find yourself in as a theme developer is the need to create content that only shows on the homepage of your community. You might add some HTML to the “After Header” section of your theme, which will then appear on every page. You can jump through some hoops in CSS to hide this everywhere except the homepage… but instead let’s use a Discourse theme to create a component with content that is only visible on your homepage. If you’re unfamiliar with Discourse themes …

```js
<script type="text/discourse-plugin" version="0.8">
  // This is the plugin outlet, followed by a custom name for the component
  api.registerConnectorClass("below-site-header", "custom-homepage", {

    // Setting up our component
    setupComponent(args, component) {

     // Next we're getting the site setting 'top_menu',
     // splitting the values into an array,
     // and adding a leading slash
     var topMenuRoutes = 
        component.siteSettings.top_menu.split('|')
        .map(function(route) {return '/' + route});
      
     // The first page listed in the 'top_menu' setting is your homepage
     // lets assign it to a variable
     var homeRoute = topMenuRoutes[0];
  
     // This calls our code whenever the page changes
     api.onPageChange((url) => {

        // Check if we're on the homepage 
        if (url === "/" || url === homeRoute ){ 
          // If it's the homepage add the 'custom-homepage' class to HTML tag
          // and set 'displayCustomHomepage' to true
          document.querySelector("html").classList.add("custom-homepage"); 
          component.set("displayCustomHomepage", true); 
        } else {  
          // If we're not on the homepage remove the class
          // and set `displayCustomHomepage` to false
          document.querySelector("html").classList.remove("custom-homepage"); 
          component.set("displayCustomHomepage", false); 
        }
      });
    }
    
  });

</script>

```

^ Add this to your `head` to add a `.custom-homepage` class to your `body` tag when you’re on the homepage, then →

```css
.custom-homepage #main-outlet-wrapper {
    margin-top: -38px;
}

```
