This plugin adds a static search engine to your Wordpress site. Static in this context means that it works in the browser without using of server-side queries, so it’s ideal for static websites generated from a Wordpress site and can also be used offline.
Since both the search and the indexing happens in the browser, this plugin is not a good fit for sites that contain hundreds of pages and posts.
After you are installed the plugin, choose the ”Static Search” option from the left sidebar of the Wordpress admin interface. Press the ”Update Index” button and wait until the indexing is finished. Each time you change the content of the website, you should update the search index manually.
To insert the search box and the search results into the site, use the [static_search] shortcode. It’s a good practice to create a page called ”Search” with the slug ”/search/” and insert the [static_search] shortcode into this page. Redirection of the search widgets to this page is provided by the plugin using JavaScript, but for server deployments performance is improved by appending the following code to the bottom of your .htaccess file:
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^(index\.html)?$ /search/?q=%1 [NC,R,END]
This code redirects the search queries to the /search/ page, then the [static_search] shortcode processes them and shows the search results.
When creating the static site, please make sure that files in the following directories are included (full paths may be needed):
/wp-content/lunr-index/
/wp-content/plugins/wp-static-search/3rdparty-css-js/
/wp-content/plugins/wp-static-search/css/
/wp-content/plugins/wp-static-search/js/
In particular, the search index file, which might not be picked up by crawlers:
/wp-content/lunr-index/lunr-index.js
lunar.js - Javascript search engine
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the Apache 2 and GPL2+ Licenses Acknowledgments
The frontend search code based on the MkDocs project’s search plugin.