Restrict Welcome banner to user's homepage

Okay, here’s a working solution. In my example, the Welcome Banner will be displayed on the /latest page only, regardless of users’ interface settings. I’ll let you customize it to display it for the /categories page only. :slight_smile:

  1. Set the Welcome Link Banner show on setting to “all” or “discovery”, depending on the page(s) you want the banner to be displayed.

  2. Add this script in your theme:

    <script type="text/discourse-plugin" version="1.4.0">
        //shows the welcome banner only on the /latest page
        api.onPageChange(() => {
            const router = api.container.lookup('service:router');
    
            if (router.currentRoute.name === 'discovery.latest') {
                document.body.classList.add('route-discovery-latest');
            } else {
                document.body.classList.remove('route-discovery-latest');
            }
        });
    </script>
    
  3. Add this CSS to your theme:

    body:not(.route-discovery-latest) .welcome-link-banner-connector {
       display: none;
    }
    

Reference used:

8 Likes