Enabling search on a static site with Google CSE

Google Programmable Search Engine can search selected public domains from an exported WordPress page. Google supplies the search box and results. You need an engine configured for the public hostname and a page where its Search Element can load.

How to set up Google CSE?

In Google Programmable Search Engine, create or select an engine and add the public site’s domain to the sites it can search. Under Overview → Basic → Get code, copy the Search Element snippet for that engine.

Google CSE in WordPress

In the WordPress editor, add a Custom HTML block to the page where visitors should search. Paste the complete snippet from Google, including its script and results container, and save. Use a WordPress account allowed to save scripts. Preview the page and confirm the search field appears. Google’s Search Element instructions.

Convert WordPress to static

Select ZIP Archive under Simply Static → Settings → Deployment and save.

Deployment method in Simply Static settings

Open Simply Static → Dashboard. Choose Full Site next to Push and select Push. Follow the Activity Log until the run finishes. Use the Export Log to check the status of individual pages and assets.

Full Site selector, Push button and Activity Log on the Simply Static Dashboard

Deploy the static site

For ZIP Archive, select Click here to download in the completed Activity Log. Extract the archive and locate the top-level index.html. Upload the contents of that directory to your static host. Open the homepage, then follow a link to a second page and check an image.

Try a phrase from a page Google has already indexed on the public domain. A new static page can be live before it appears in Google’s results. If the search field is missing altogether, check whether WordPress preserved the script and whether your consent or content security settings allow it to load.

Summary

For later edits, publish the changed WordPress page and check it under the public domain. Changes to the set of domains Google searches are managed in the engine’s own control panel.

START WITH YOUR OWN WEBSITE

See whether static fits your next project.

Run the free compatibility check first, or try a private copy in Simply Static Studio.