Put the Search Page on Your Website
Two lines of code put the hosted search page of your Opensolr Index inside any page of your own website. Visitors search without leaving your site, and everything you set up in the Control Panel works there too: facets, sorting, Query Elevation, Search Tuning and, when you switch it on, the chat bot.
Add it in four steps
- Open your index in the Control Panel and go to the WebCrawler tab.
- Click Settings in the Quick Access bar, then open Search Embed Code.
- Copy the two lines. They already carry the name of your index:
<div id="opensolr-search" data-index="YOUR_INDEX_NAME"></div> <script src="https://search.opensolr.com/embed.js" async></script> - Paste them where the search should appear, for example on a page called Search that your menu links to. Save and open the page.
Good to know
- Any website. It works on any site where you can add HTML, in any CMS or site builder. There is nothing to ask Opensolr and no domain to whitelist.
- Size. The search fills the width of the place where you put it. Its height is the space left on the screen below where it starts, at least 520 pixels, and it adjusts when the window changes size or a phone is turned.
- No human check. Visitors who open search.opensolr.com directly pass a short human check first. Inside your website there is none.
- Options. Theme, layout, a first search, the Documents tab and more are set with
data-attributes on the div: Embed code options. - Password. A password-protected search page stays protected inside your site too: without the username and password it shows nothing.