I want to add Google Custom Search Engine to my forum. Could you please suggest, where and how to add the Custom Search Engine Code to discourse.
Discourse already comes with a pretty powerful search feature. Why would you want to add Google custom search engine?
Yeah have to agree, Discourse search works well. Iâve never found a Google custom search implementation that worked well. Even if wanting ad revenue from it I think it would be a negative Impact overall.
I believe there is nothing wrong in trying it out and see the revenue impact. If things wont work, we can switch back anytime. But, how to implement is what I wanted to figure out.
Could someone help me here.
I canât imagine it would be easy to override the built in search functionality of Discourse. Itâs tightly knit into the very foundation of the Discourse app and works at the database level.
Google custom search as far as Iâm aware will just build an index of the static site content, it would be a lot worse than whatâs already there. Not to mention how you would integrate it into the Discourse UI (the Ember app)
I really donât know how you would make it work (or why youâd want to!)
You may need to build a theme component to replace/modify the default search compoment or widget with what your want.
Iâm not particularly familiar with Google Custom Search, but my understanding is that it would only be able to search public topics. Assuming thatâs true, that means your users wonât be able to search their PMs, topics in non-public categories, tags/users/groups (we block indexing for those pages), etc. If thereâs a way to give Google admin access to your site, that may solve some issues, but opens up other (privacy) issues.
We do support Algolia, see Add Algolia search to your Discourse.
Iâm fairly sure that it only includes pages that are indexed by G also. Which is often only a small % for UGC.
It is not necessary nor a good idea to replace the internal discourse search functionality.
However, there is nothing wrong with adding an additional search capability, Google or otherwise.
This is best done with a plugin and its own route / page.
My advice @KranthiKiranGude is to leave the discourse search feature as-is and create a plugin with a distinct page / route for GCS.
That is exactly what we did with our old LAMP forum, BTW.
@neounix: I am not trying to override the existing search functionality of discourse. I am just trying to add a widget or a plugin, I would be great, if some could suggest how to add a custom HTML component like Google Custom Search Engine to all the pages. I would keep the existing search functionality of discourse as-is. Just wanted to check the revenue impact.
Based on prior experience implementing GCSE on a forum application, I suggest two plugins:
-
Theme component for the GCSE search bar. You can then place these GCSE search bars where ever you want on your site. This is fairly simple to do.
-
Plugin to create a Discourse page (route) to display your GCSE search results. This will be a bit more complicated than the theme component (to show the search bar); so you might want to post in the Meta Marketplace and ask one of the fine Discourse plugin developers to assist you.
If you go this route, please do consider sharing this plugin with the community here.
Thanks!
Hi @neounix,
Could you please help me with a sample code snippet for you suggestion 1. I have tried pasting GCSE Code in section in the theme, but It is not visible, when I previewed it.
Thank You.
The link below is a good starting place. You can also enjoy searching meta for the keywords, âtheme componentâ.
See also:
And also https://github.com/topics/discourse-theme-component
(sample code):
Enjoy!
I have included the GCSE script in " Edit CSS/HTML" section. But, The search box is not appearing. I could see the code in page source. But, the element is not visible on the UI
Earlier when discourse search threw zero results, then there appeared a button labelled âsearch your site with googleâ.
It was no more helpful than just to open google search with already filled with this:
"site:yoursitename.com "