Standalone Search in Nikola
This has been in the master branch of Nikola for a while but only now have I tried to fully integrate it, and polish all (most) of the rough edges.
By default, Nikola comes with support for search forms using Google and Duckduckgo. Some people disapprove of them for different reasons [1] so there was a request about supporting a standalone search engine.
The best of breed of those things seems to be Tipue so that's what I supported.
To use this, you need to enable a plugin, and do some configuration changes.
The plugin is called task_localsearch
and you can find it in
the Nikola source tree
Suppose your site is in a folder called mysite
then to enable this plugin you need
to create mysite/plugins
and then copy task_localsearch.plugin
and task_localsearch
in there.
Then, in your site's conf.py
find these options and change them accordingly:
SEARCH_FORM = """ <span class="navbar-form pull-left"> <input type="text" id="tipue_search_input"> </span>""" ANALYTICS = """ <script type="text/javascript" src="/assets/js/tipuesearch_set.js"></script> <script type="text/javascript" src="/assets/js/tipuesearch.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#tipue_search_input').tipuesearch({ 'mode': 'json', 'contentLocation': '/assets/js/tipuesearch_content.json', 'showUrl': false }); }); </script> """ EXTRA_HEAD_DATA = """ <link rel="stylesheet" type="text/css" href="/assets/css/tipuesearch.css"> <div id="tipue_search_content" style="margin-left: auto; margin-right: auto; padding: 20px;"></div> """
How does it work? Here's a demo site for you to try!
I would not recommend doing this for a big site, since it may load a multi-megabyte javascript file when you search, but for small to medium sites, it may be ok.