Hide Discourse's search and use Google's

Hello my friends

My forum is getting a lot of searches from anonymous users not registering or valuing the true essence of the community (which is helping others), so I have decided to create a component to remove the native discourse search engine (it really hides it) and show only the Google search engine, which searches within the forum’s domain (indexed content) and at the same time puts up advertising so it monetizes the searches by adsense.

So this component eliminates the ability for users to use Discourse’s native search engine. Instead, they will use the search engine powered by Google, and it allows adding monetization through it.

My original idea is to remove the native Discourse search engine for anonymous and users with TL0 - TL1, while to the rest of the registered users, hide the new Google search engine and show them the native one.

I wanted to put the search engine on the " header " section, however I couldn’t find a way via CSS to place it inside the " panel clearfix " class. I’m sure someone on the forum can help out with this.

Finally I did some css changes and put the Google’s search into the header nav:


Hopefully someone will join the idea and we will improve this development together!

You take care of yourself and we all take care of ourselves! :mask:

Why not a Theme Creator preview?

:exploding_head: About theme-creator, I tried to configure a new “google-search” to do testing directly from the theme-creator, but I get the error: “Refused to load the script ... because it violates the following Content Security Policy directive:" script-src ....


great work. I’ll check this… can u share your site url or somewhere where I can see it working on demo. or share ur site url.

is this Google adsense custom search bar? do u have a way to keep both discourse native and also adsense custom search together on 1 page? I really like the autosuggest feature of discourse native search.

Does this work on amp pages of discourse?

Search for content security policy setting, you can add those URLs in allowed list which adsense search calls and uses , then it should work.

1 Like

Yes I have. Native is “hidden”, and yes, it’s google custom search bar. In my case, I configured with ads.

I don’t know that, my site isn’t amp … sorry.

About demo, I edited my first message with more info and new version.

Yes, I knew that, but I’m not admin from Theme Creator so I can’t add the site to allowed list.

BTW, layout is broken on Safari/iPad