TailTemplate Build stunning websites faster with our pre-designed Tailwind CSS templates

How to Integrate Google Programmable Search Engine to Laravel

Programmable Search Engine lets you include a search engine on your website. Because it is based on Google's core search technology, you can be confident that your users are getting high-quality, relevant results.

Instead of building your custom search engine for your website. Programmable search engine is a great alternative for saving your development time.

In this post, we will demonstrate how to integrate Google's programmable search engine into a Laravel project.

Setup Programmable Search Engine

Firstly you need to register your site with programmable search engine at https://programmablesearchengine.google.com/. You will be prompted to validate your ownership of the site and so on.

Get the search code

  • Click the Look and feel tab and choose the style of the search box.
  • Click the Save & Get Code button at the bottom of the page.
  • You should be redirected to a new page showing you the code for the search box. Create a component file in your Laravel project resources/views/components/search.blade.php and copy the search box code over:

Render the search box in your Laravel project

Since we have obtained the search box code and saved them in resources/views/components/search.blade.php. Simply place the component anywhere you wish to show the search.

In our project, we choose to render them on the home page by calling <x-search/> in our view:

That is all for integrating Google Programmable Search engine into our site.

Google provides a lot of flexibility when it comes to customizing the search box. You can choose a template, customize the theme and enable automatic thumbnails for search results: