Provides very basic search functionality, loosely ranking results based on number of matches per page. To be improved for better search results.
- Create a page with any name you like, for example "search". In the meta section include
Purpose: search_results
. - In your template provide a basic HTML form with an input field named
q
, method GET, and action URL pointing to the page you have created. - Add the following code to your template near the {{ content }} tag:
{% if meta.purpose == "search_results" %}
<p class="meta">{{ search_num_results }} page(s) found for "{{ search_term }}"</p>
{% for page in search_results %}
<h4><a href="{{ page.url }}">{{ page.title }}</a></h4>
{% if page.date %}<p class="meta">{{ page.date_formatted }} by {{ page.author }}</p>{% endif %}
<p class="excerpt">{{ page.excerpt }}</p>
{% endfor %}
{% endif %}