How to add Google Adsense Custom Search Box on Discourse Search page?

AI-generated summary

Adding Google Adsense Custom Search Box on Discourse Search Page

user1 wants to monetize their forum using Adsense search ads by adding a custom search box and results on the Discourse search page. They received two JavaScript codes from Adsense: one for the search box and one for the search results page. However, they encountered syntax errors when trying to add these codes to their Discourse forum using Handlebar JS.

codinghorror doubts the feasibility of this approach in Discourse. Alternatively, SidV suggests exploring a custom component they created, which allows hiding Discourse’s search and using Google’s instead.

Also, it is great way to monetize the forum using Adsense search ads when people search for topics on discourse.
Adsense gave me 2 codes,

  1. one for showing the search box and search icon
  2. ONE to place on the actual search page which is Search results for '' - Discourse Meta

But they both are JS script tags and if i follow this Add custom content that only appears on your homepage and try to add the JS script tag inside the Handlebar JS code, it gives me syntax error, i am unable to put the script tag inside it.

Please see Add an AdSense search engine to your site - Google AdSense Help

The 2 codes look something like this:

<script async src='https://cse.google.com/cse.js?cx=3d0aca23447b4f'></script><div class="gcse-searchbox-only"></div>

And the other one
<script async src='https://cse.google.com/cse.js?cx=3d0aca234fcfb'></script><div class="gcse-searchresults-only"></div>

Where and how can i put these on my disocurse forums so they can be rendered correctly on correct places?

I don’t think this will be possible in Discourse.

I created a component about this topic, you might be interested in: Hide Discourse's search and use Google's