From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: stable
Implementation Search
Description Adds to or replaces MW Special:Search results with Google CSE results
Author(s) Ryan Finnie (Fo0bartalk)
Latest version 3.0 (2016-08-21)
MediaWiki 1.25+
License GNU General Public License 2.0 or later
Download Download latest stable release (3.0), or:
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.


  • 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:
    wfLoadExtension( 'GoogleSiteSearch' );
    $wgGoogleSiteSearchCSEID = 'YOUR_CSE_ID';
  • 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.
  • Configure further if required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension(). If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'GoogleSiteSearch' );, you need to use:

require_once "$IP/extensions/GoogleSiteSearch/GoogleSiteSearch.php";


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.
  • $wgGoogleSiteSearchAttributes - An array of optional Custom Search element attributes. For example, to make links open in a new window/tab:
    $wgGoogleSiteSearchAttributes = array( 'linkTarget' => '_blank' );

In addition, the HTML built by the extension is customizable via the GoogleSiteSearchHTML hook. For example:

function MyGSSHTML( $specialSearch, $term, &$html ) {
    $html .= '<p>Example append</p>';
$wgHooks['GoogleSiteSearchHTML'][] = 'MyGSSHTML';

See also[edit]