Publican v0.10.0 update and StaticSearch
660 words, 4-minute read

Publican v0.10.0 was released on .
There are no breaking changes, but the following features have been improved and a new static site search engine is available.
Better performance logging #
Previous releases of Publican could conflict with other applications recording Node.js performance
metrics. This has been fixed using PerfPro – a new profiler that namespaces applications so records cannot clash.
Publican and related tools such as LiveLocalhost and StaticSearch have also adopted ConCol for prettier and less cluttered console logging:

Introducing StaticSearch #
This site is fairly large. While it offers reasonable navigation and tags, finding the page you want can be tricky.
Static sites cannot easily provide search facilities because there’s no back-end database. You can integrate a third-party search service such as Alogia, AddSearch, or Google’s Programmable Search Engine. These index your site and provide a search API, but have an ongoing cost.
JavaScript-only search facilities such as Lunr require you to pass all content in a specific format. Every page then has a full index of your site, so the payload can become large as your site grows.
My preferred option is pagefind. This analyses your built site and creates WASM binary indexes. Unfortunately, it can require some configuration, produces quite large files, and has problems with Content Security Policies and Safari compatibility.
So I’ve rolled my own…
StaticSearch is my new search engine for static sites. It’s enabled on Publican.dev: click the search icon in the header or press Ctrl | Cmd + K.
StaticSearch is easy to use and fully compatible with Publican, but you can use any static site generator. It:
- quickly indexes built HTML (like pagefind)
- is pure JavaScript without any CSP issues, and
- has a tiny payload and no AI nonsense.
At most, the search facility requires 13Kb of JavaScript and 4Kb of CSS. You can reduce that to just 6Kb if you’re building your own UI. Word index data typically totals:
- 100Kb for a 100 page site
- 800Kb for a 1,000 page site.
Index data is incrementally loaded on demand as you search for different words. Indexes are cached in IndexedDB so results appear faster the more searches you do.
StaticSearch quickstart #
Assuming your static site has been generated in a sub-directory named ./build/
, run StaticSearch using:
npx staticsearch
It creates a new directory named ./build/search/
containing JavaScript code and index data.
If your site is in a different directory, such as ./dist/
, use:
npx staticsearch --builddir ./dist/ --searchdir ./dist/search/
You can now add a search facility to the site using HTML code on any/all pages:
<script type="module" src="/search/staticsearch-component.js"></script>
<static-search>
<p>search</p>
</static-search>
Any HTML element can be placed inside <static-search>
to activate the search when it’s clicked. You may then need to rebuild your site and re-run staticsearch
to ensure everything’s up to date.
StaticSearch is new – full documentation will appear on Publican.dev shortly.
Minor redesign of Publican.dev #
This site’s been updated to provide search and reduce the clutter in the header.
Get started #
The Publican documentation provides a quick start guide, a detailed set-up guide, API references, and common recipes you can use and adapt for your own projects.