Adding a DuckDuckGo search box to your blog

I wanted to add a search to this blog. First I looked at adding a google site search. However, it's a script-based approach and it adds a ton of generated markup to the page.

I then found that DuckDuckGo have a search widget. The immediate downside was that this is included via an iframe. However, I then found this snippet at the bottom of the page.

You can also make and style your own box like our founder has on his blog (that one has a blue button, for example).

Excellent I can do this cruft free.

Here's the markup:

<form class="ddg" name="x" action="//duckduckgo.com/">
    <input type="hidden" value="muffinresearch.co.uk" name="sites"></input>
    <input type="hidden" value="1" name="kh"></input>
    <input type="hidden" value="1" name="kn"></input>
    <input type="hidden" value="1" name="kac"></input>
    <input type="search" placeholder="Search" name="q"></input>
    <button class="button" type="submit">GO</button>
</form>

This adds the basic form and a few options.

To see the parameters you can use see the params documentation here.

With all that in place and a bit of custom styling I now have a fairly decent site search powered by DuckDuckGo, with no-added-cruft.

Show Comments