frjo / hugo-theme-zen

A fast and clean Hugo base theme with css-grid and Hugo pipes support.
https://zen-demo.xdeb.org/
GNU General Public License v2.0
276 stars 80 forks source link

Search Form in Sidebar, #55

Closed arky closed 2 years ago

arky commented 2 years ago

I have added the following code to top of sidebar partial in my layouts folder. I would like to post to /search page that contains search partial and show results.


  <section>
  <form id="search-form" class="search-form" action="/search" method="post" accept-charset="UTF-8" role="search">
    <label for="query" class="visually-hidden">{{ i18n "search_title" }}</label>
    <input type="search" id="query" name="query" class="search-text" placeholder="{{ i18n "search_placeholder" }}" maxlength="128">
    <button type="submit" name="submit" class="form-submit" >{{ i18n "search_title" }}</button>
  </form>
 </section>

The search.md page contains the following.

---
title: "Search"
searchform: true

---

{{< search >}}
frjo commented 2 years ago

That will not work.

You might be able to add some javascript that makes the search term carry over to the search page. Can't give you mush more than that, javascript is not my forte.