Enabling visitors to search your website

Note

The storefront search is a fully featured, powerful tool for your customers to search across all of your shop's products, articles, and pages.

Using AND, OR and NOT operators

AND

All search terms are by default AND-ed together, so searching for

artichoke hearts

will search results containing both "artichoke" and "hearts". No joining operators are necessary.

OR

Searching for

artichoke OR hearts

will give results containing at least one of "artichoke" or "hearts".

NOT

Searching for results without a term can be done by prefixing the term with a minus sign.

artichoke -heart

will match things with "artichoke" but not "heart".

Searching only for certain types

You can restrict the type of objects that get returned by the search for the storefront search. For example a realistic use case would be to only return products for your customers and not pages or articles.

To only return products you can include the type query parameter like this:

/search?q=snowboard&type=product

Or to only search for articles and pages with a certain text in the body:

/search?q=snowboard&type=article,page

Where type can be any of combination of product, article, and page separated by commas. All three types are searched for if none are specified.

This can be accomplished using a hidden field in the search form within search.liquid.

<form method="get" action="/search">
   <input type="hidden" name="type" value="product" />
   ...
</form>

Searching specific fields

Prefix a term with a field name and colon to narrow your search for that term to the specified field.

For example:

 title:artichoke

will search for things with artichoke specifically in their title.

The following fields are available to use:

Product fields

title
handle
body
vendor
product_type
tag
variant
sku

Page fields

title
handle
body
author

Article fields

title
body
author

Want to add an auto-complete search feature to your storefront? Check out the Swiftype app, and using Shopify's built-in search engine to add the same autocomplete feature.

Want to discuss this page?

Visit the Shopify Community

Ready to start selling online with Shopify?

Try it free