Advertising sustains the DA. Ads are hidden for members. Join today

Contributed module documentation

Google Programmable Search Engine

Last updated on
18 March 2024

This module allows the Drupal core search form to return site-specific search results from Google. You control which site(s) are indexed. It supports all configuration provided by the Programmable Search Element API. Theming is the responsibility of the site owner.

Background

Basic Setup

1. Install this module as you normally would.
2. Create a new Google PSE instance at https://programmablesearchengine.google.com/about/
3. Go to Configuration > Search Pages (/admin/config/search/pages) and create a new search page of type "Google PSE search". Enter the PSE ID from the previous step.
4. Place the core Drupal "Search" block in your layout. Searches will return results from Google.

Additional settings through Google's Element Control API

You can use optional attributes to overwrite configurations created in the Programmable Search Engine control panel. For example, including data-lr="lang_fr" will restrict results to documents written in French.

Enter these data attributes as key/value pairs, where the key is data-ATTRIBUTE_NAME and the value is the ATTRIBUTE_VALUE.

Some more common settings available through this interface:

  • Customize the "no results" message
  • Open results in a new tab/window
  • Restrict results to pages from a specific site
  • Restrict results to matches in a specific language

Help improve this page

Page status: No known problems

You can: