Updated code example for results page

Otherwise, if no results found, twig produces an error message that breaks down the whole website/page.
This commit is contained in:
Christian Becher
2016-11-09 08:43:20 +01:00
committed by GitHub
parent 037e4b8386
commit 62a7111643

View File

@@ -28,12 +28,14 @@ Your template file (`search.html` in the above example) should contain something
lists the pages matching the search (substitute `paged_pages` for `pages` if using Pico-Pagination):
```twig
{% for page in pages %}
<div class="search_result">
{% if pages %}
{% for page in pages %}
<div class="search_result">
<h2><a href="{{ page.url }}">{{ page.title }}</a></h2>
{% if page.description %}<p>{{ page.description }}</p>{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
{% endif %}
```
Now, you should be able to visit for example `yoursite.com/search/foobar` (adjust path accordingly if putting search.md