search_form

Table of contents

Renders a form with a text input as a search form. The first argument must be the query flag that is used to send the search query with as URL parameter.

Also accepts the following arguments:

  • url: The URL to show the search results on (Optional, default: current url)

  • form_class: The html class for the search form tag. (Optional)

  • Every other key-value argument will be used as html tags for the input.

The following generates a GET request for the search page '/search'.

When submitted, the search form makes a GET request to the following url: '/search?q=<search query>'.

Input:
{% search_form "q", url: "/search" %}

Output:

<form action="/search" class="">
  <input type="text" name="q" value="">
</form>
💡 You can also easily create your own form, as long as the page your action points to has a search_results tag and uses the query object parameter to populate the search string.

Need help?

Do you have any question which is not answered in this knowledge base? Contact us. We are here to help you.