# How to add Google Custom Search Engine to Discourse

**URL:** https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159
**Category:** Support
**Created:** [July 8, 2020, 3:21pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159 "2020-07-08T15:21:20Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![KranthiKiranGude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kranthikirangude/32/135387_2.png) [@KranthiKiranGude](https://meta.discourse.org/u/KranthiKiranGude)
#### Post date: [July 8, 2020, 3:21pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/1 "2020-07-08T15:21:20Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jamesmarkcook](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesmarkcook/32/168563_2.png) [@jamesmarkcook](https://meta.discourse.org/u/jamesmarkcook)
#### Post date: [July 8, 2020, 4:28pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/2 "2020-07-08T16:28:29Z")

</div>

Discourse already comes with a pretty powerful search feature. Why would you want to add Google custom search engine?

---

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [July 8, 2020, 4:38pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/3 "2020-07-08T16:38:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![KranthiKiranGude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kranthikirangude/32/135387_2.png) [@KranthiKiranGude](https://meta.discourse.org/u/KranthiKiranGude)
#### Post date: [July 8, 2020, 4:40pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/4 "2020-07-08T16:40:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jamesmarkcook](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesmarkcook/32/168563_2.png) [@jamesmarkcook](https://meta.discourse.org/u/jamesmarkcook)
#### Post date: [July 8, 2020, 4:46pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/5 "2020-07-08T16:46:11Z")

</div>

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!)

---

<div class="post-metadata">

### Author: ![hawm](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hawm](https://meta.discourse.org/u/hawm)
#### Post date: [July 8, 2020, 4:52pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/6 "2020-07-08T16:52:09Z")

</div>

You may need to [build a theme component](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648) to replace/modify the default search compoment or widget with what your want.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [July 8, 2020, 5:02pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/7 "2020-07-08T17:02:42Z")

</div>

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 [Discourse Algolia Search](https://meta.discourse.org/t/add-algolia-search-to-your-discourse/73517).

---

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [July 8, 2020, 5:14pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/9 "2020-07-08T17:14:03Z")

</div>

> [@jomaxro](#):
>
> I’m not particularly familiar with Google Custom Search, but my understanding is that it would only be able to search public topics.

I’m fairly sure that it only includes pages that are indexed by G also. Which is often only a small % for UGC.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [July 8, 2020, 5:21pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/10 "2020-07-08T17:21:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![KranthiKiranGude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kranthikirangude/32/135387_2.png) [@KranthiKiranGude](https://meta.discourse.org/u/KranthiKiranGude)
#### Post date: [July 9, 2020, 5:42am UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/11 "2020-07-09T05:42:46Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [July 9, 2020, 7:28am UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/12 "2020-07-09T07:28:00Z")

</div>

Hi @KranthiKiranGude

Based on prior experience implementing GCSE on a forum application, I suggest two plugins:

1. 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.

2. 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!

---

<div class="post-metadata">

### Author: ![KranthiKiranGude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kranthikirangude/32/135387_2.png) [@KranthiKiranGude](https://meta.discourse.org/u/KranthiKiranGude)
#### Post date: [July 9, 2020, 12:48pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/13 "2020-07-09T12:48:06Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [July 9, 2020, 1:02pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/14 "2020-07-09T13:02:28Z")

</div>

> [@KranthiKiranGude](#):
>
> 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.

Hey @KranthiKiranGude

The link below is a good starting place. You can also enjoy searching meta for the keywords, “theme component”.

> [@Beginner's guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966):
>
> This is a crash course in Discourse theme basics. The target audience is everyone who is not familiar with Discourse themes. If you’ve already used Discourse theme / theme components, this guide is probably not something you need to read. What are themes and theme components? A theme or theme component is a set of files packaged together designed to either modify Discourse visually or to add new features. Let’s start with themes. Themes In general, themes are not supposed to be compatible …

See also:

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

And also `https://github.com/topics/discourse-theme-component` (sample code):

[https://github.com/topics/discourse-theme-component](https://github.com/topics/discourse-theme-component)

Enjoy!

---

<div class="post-metadata">

### Author: ![KranthiKiranGude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kranthikirangude/32/135387_2.png) [@KranthiKiranGude](https://meta.discourse.org/u/KranthiKiranGude)
#### Post date: [July 9, 2020, 3:44pm UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/15 "2020-07-09T15:44:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [August 14, 2025, 8:01am UTC](https://meta.discourse.org/t/how-to-add-google-custom-search-engine-to-discourse/157159/16 "2025-08-14T08:01:10Z")

</div>

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 "
