--- layout: default title: search nav: group: Liquid Variables --- # search The search object has the following attributes: {% table_of_contents %} {% anchor_link "search.performed", "search-performed" %} Returns true if an HTML form with the attribute action="/search" was submitted successfully. This allows you to show content based on whether a search was performed or not.
{% highlight html %}{% raw %} {% if search.performed %} {% endif %} {% endraw %}{% endhighlight %}
{% anchor_link "search.results", "search-results" %} Returns an array of matching search result items. The items in the array can be a: - product, - article, - page. You can access the attributes of the above three objects through search.results.
{% highlight html %}{% raw %} {% for item in search.results %}

{{ item.title | link_to: item.url }}

{% if item.featured_image %}
{{ item.featured_image.src | product_img_url: 'small' | img_tag: item.featured_image.alt }}
{% endif %} {{ item.content | strip_html | truncatewords: 40 | highlight: search.terms }} {% endfor %} {% endraw %}{% endhighlight %}
{% anchor_link "search.results_count", "search-results_count" %}

Returns the number of results found.

{% anchor_link "search.terms", "search-terms" %}

Returns the string that was entered in the search input box. Use the highlight filter to apply a different style to any instances in the search results that match up with search.terms.

Input

{% highlight html %}{% raw %} {{ item.content | highlight: search.terms }} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} Yellow shirts are the best! {% endraw %}{% endhighlight %}