staticsearch
v0.8.0
Published
Simple static site search system.
Downloads
108
Maintainers
Readme
StaticSearch
StaticSearch is a simple search engine you can add to any static website. It uses client-side JavaScript and JSON data files so there's no need for back-end server technologies or databases.
StaticSearch works with Publican sites but you can use it with any static site generator that outputs HTML pages. It works best on English sites, but supports most Latin-based languages.
Full documentation is available at staticsearch.com
View the CHANGELOG for updates
To use StaticSearch, build your static site to a directory, then:
Index the pages to create JavaScript and JSON data files (do this every time your site changes).
Add search functionality to your site following the first index.
Index your site
Assuming you've generated your static site to a sub-directory named ./build/, run the StaticSearch CLI command:
npx staticsearchStaticSearch creates a new directory named ./build/search/ containing JavaScript code and word index data.
If your site is in a different directory, such as ./dist/, use:
npx staticsearch --builddir ./dist/For help, refer to StaticSearch indexer or view CLI configuration help:
npx staticsearch --helpenvironment variable configuration help:
npx staticsearch --helpenvor Node.js API configuration help:
npx staticsearch --helpapiAdd search functionality to your site
StaticSearch provides four ways to add a search facility on your site. The easiest is a single <script> tag placed inside your pages perhaps in the HTML <header>:
<script type="module" src="/search/staticsearch-here.js"></script>This displays a icon in the script's location on the page that opens a search dialog when clicked.
If necessary, you can now rebuild your site to include this update and re-run the indexer to ensure word indexes are up-to-date.
For full help, refer to:
StaticSearch script: adds search functionality with a single
<script>StaticSearch web component: provides full search functionality
StaticSearch bind module: attach search functionality to custom HTML
<input>and result elementsStaticSearch JavaScript search API: create your own custom search functionality.
