Is it possible to display a banner at the top of my homepage?

Hi everyone. Is it possible to write custom code to display a small banner at the top of my website homepage? I want to use it as an advert slot (for context, my website is an AI tool directory -

I would need to make the banner clickable so that it directs users to whatever website I set it to go to.


Would that be of interest for you?


I would suggest starting with a header block, and playing around with the text you can add to it to see if it can meet your needs.

If it works, display the ad header above your normal header.


Hey @Gen,

The tool @matthieu_chateau mentioned is very close to what you need, just wanted to let you know that it does not work with the Fixed header, so when you setup the Notification Bar tool, make sure the header i snot fixed.

1 Like

Thanks Matthieu, I’ll check it out tonight but it looks like exactly what I need.

Thanks for the suggestion. I did try with the header block but was not able to achieve the desired outcome.

Thanks for the tip Suzie. I’ll try it and and report back here.

Hi @matthieu_chateau and @Suzie. I just tried the banner code now and it works well. The only issue is, the content isn’t centred on desktop view (please see attached image). Could this be because of the vertical menu on the left? (I took the screenshot in preview mode)

The tab and mobile views seem fine

Yes it’s because of the left vertical navbar

Thanks @matthieu_chateau . Do you know if there’s anything I can do about it?

And also, do you know if there’s a way to reduce the width of the vertical navbar?

To reduce the width of the vertical navbar, insert this code in page settings => custom code => header.

Change the two 240 to whatever you want + change “home-header” by the ID/name of your header

@media only screen and (min-width: 992px) {
#home-header {
    margin-left: 0 !important;
.content[data-appid] > * {
  margin-left: 240px!important;
1 Like

To adjust the banner text, I just can see these two lines of code in the script to update to whatever you want: = "center"; // replace center by right

or = "center";

Also, a more readable version of the script would be: (I added padding left and right also, might help)

  configObj = {
    "text": "We’re live on ProductHunt right now! Support us and get your exclusive LIFETIME DISCOUNT!",
    "bannerURL": "",
    "selectedBackgroundColor": "#69C3FF",
    "selectedTextColor": "#181818",
    "bannerHeight": "64px",
    "fontSize": "15px"

  function createBanner(obj, pageSimulator) {
    var swBannerLink = obj.bannerURL;
    var swBannerTarget = "_blank";
    var swBannerText = obj.text;
    var body = document.body;
    var swBanner = document.createElement('a');
    var centerDiv = document.createElement('div');
    var text = document.createElement('span');

    swBanner.href = swBannerLink; = swBannerTarget; = "flex"; = "center"; = "center"; = "100%"; = "48px"; = "72px"; = "8px"; = "8px"; = "20px"; = "20px"; = "18px"; = "center"; = "none"; = obj.bannerHeight; = obj.fontSize;
    text.innerHTML = swBannerText; = obj.selectedBackgroundColor; = obj.selectedTextColor; = 'sw-banner';

    if (!pageSimulator) {
      body.insertBefore(swBanner, body.firstChild);
    } else {
      pageSimulator.insertBefore(swBanner, pageSimulator.firstChild);

  document.addEventListener("DOMContentLoaded", function () {
    createBanner(configObj, null);

Thank you very much. I have been able to successfully reduce the width of the vertical nav bar and it looks much better.

Thanks for responding to this as well. Unfortunately I tried it and the padding didnt seem to make a difference on the desktop view but did to the tab and mobile views. I even tried adding spaces before the text but didn’t get results. Not sure if there’s anything else I can do to get the code to only consider the space after the vertical nav bar so that the text ends up truly in the centre of that part of the screen.

Remove this line: = "100%";

and add this inside the custom code header, below the script

.sw-banner {
  width: 100%;

@media (min-width: 769px) {
  .sw-banner {
    width: 120%; //increase or decrease this percentage to find you needs


That worked perfectly well. Thank you soo much for your help @matthieu_chateau - I really appreciate it.

1 Like