From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status beta

ImplementationTemplate:Extension#type Search
DescriptionTemplate:Extension#description Adds to or replaces MW Special:Search results with Google CSE results
Author(s)Template:Extension#username Ryan Finnie (Fo0bartalk)
Latest versionTemplate:Extension#version 2.2 (2014-04-14)
MediaWikiTemplate:Extension#mediawiki 1.21+
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download Download latest stable release (2.2), or:
ExampleTemplate:Extension#example finnix.org search result

Translate the GoogleSiteSearch extension if it is available at translatewiki.net

Check usage and version matrix.

The GoogleSiteSearch extension allows you to add Google Custom Search Engine (CSE) results to "Special:Search" additionally to MediaWiki search results, or optionally, replace them altogether.

For an example, please see this search result on finnix.org.


  • Go to the Google CSE management page and add a custom search engine.
  • Make a note of the "Search engine unique ID". It should be in the format numbers:letters.
  • Download and place the file(s) in a directory called GoogleSiteSearch in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/GoogleSiteSearch/GoogleSiteSearch.php";
  • Add the following line after the previous line of code (replacing YOUR_CSE_ID with the search engine ID noted above):
$wgGoogleSiteSearchCSEID = 'YOUR_CSE_ID';


The following configuration globals are available:

  • $wgGoogleSiteSearchCSEID - The ID of the created Google custom search engine. Required.
  • $wgGoogleSiteSearchOnly - Whether to replace the the MediaWiki search results. If true, only the CSE search results are shown. If false, the CSE results are shown above the MediaWiki results. Optional, defaults to false.
  • $wgGoogleSiteSearchCharset - Character set of the data passed to the HTML template; you should not need to modify this in most cases. Optional, default 'UTF-8'.

In addition, the HTML built by the extension is customizable. The defaults are usually sufficient (configuration values replaced automatically, search term inserted, and the user's language preference is passed on to the CSE code automatically). However, if you wish to modify the HTML, copy GoogleSiteSearch.content.default.html to GoogleSiteSearch.content.html and modify.


Translation of the extension strings is managed by Translatewiki.net (direct extension link). Please contribute translations there.

Internationalization of the Google results themselves is handled by passing the user's (or site default's) language preference to Google CSE. This is handled automatically and requires no configuration.

Modification of older MediaWiki releases[edit]

This extension relies on a MediaWiki hook which was released with MediaWiki 1.21. If you would like to use this extension with MediaWiki 1.20 or earlier, you will need to modify the MediaWiki source to add the hook.

Edit includes/specials/SpecialSearch.php and look for the following comment, somewhere around line 280:

 // start rendering the page

Insert the following code above that comment:

    if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
        # Hook requested termination
        wfProfileOut( __METHOD__ );

See also[edit]