I've recently re-did the Sacramento Science Olympiad website using Steady, a static site generator I recently wrote for the purpose, and wanted to add search functionality to the site to make it easier to find content. I didn't want to muck around with a custom search engine for the website so I decided to just let DuckDuckGo handle it.
My first attempt was to use their search widget:
As I decided where to place the box, I realized I didn't like the way it looked and the widget doesn't give me enough options to customize it.
After some digging, I discovered the easiest way to add site search is with a simple form tag:
<form action="http://www.duckduckgo.com/" method="get" id="duck-duck-go-search"> <input type="hidden" value="http://sacramentoscienceolympiad.com" name="sites"> <input type="text" value="" size="20" name="q" placeholder="search"> </form>
The key here is the hidden input that sets the site search. DuckDuckGo supports a lot of customization options for the search page, as outlined in their URL Parameters page but for some reason this one is not listed.
The result is a fully customizable search box with minimal code.
Now I just need to wait for DuckDuckGo to scrape the new website and eventually replace all of the old dead links with the new documents.