Add Site Search to Your WebHaste Site (No Server Required)

Most small websites eventually hit the same moment:
A visitor lands on your site, knows what they want, and starts hunting through menus. However, studies show that 30%-50% of visitors would prefer a keyword search to menus and links alone.
A simple search box provides that.
With WebHaste v0.2.0 and higher, you can add site search that looks through every page on your site - no server, no third-party service, and no complicated setup.
What you get
When you publish your site (or render it to a local folder), WebHaste automatically generates a file called:
- search-index.json
It lives at your site root and contains a lightweight, searchable extract of each page:
- Title
- Description
- Main text content
You do not need to turn anything on to generate the data. If you publish, you get the index.
Then, if your template includes a search box, WebHaste wires it up automatically.
The best part: it runs entirely in the visitor’s browser
This is client-side search.
That means:
- It works with static website hosting providers like Netlify and Cloudflare
- No database
- No server-side code
- No separate script or app to crawl/index your site
- No external search provider
- No tracking or data leaving your site
Your visitor’s browser downloads your search-index.json and searches it locally using a small library called Lunr.js (bundled with WebHaste).
If you use the official starter templates, search is already included
If you’re using one of the official starter projects:
…search is already wired in for the latest versions.
Look for the search box in the header.
(If you removed it, you can add it back - the feature is still there.)
If you’re building your own template, you only need a couple lines
To add search to a custom template, you do two things:
1) Add two scripts in your template head
Add these script tags in your template’s <head>:
- <script src="/scripts/lunr.min.js"></script>
- <script src="/scripts/search.js"></script>
2) Add a search input and a results container
Place these anywhere you want the search UI to appear:
- <input type="search" id="cs-search-input" placeholder="Search..." />
- <div id="cs-search-results"></div>
That’s it.
WebHaste looks for those two element IDs and connects everything automatically.
No search box = no slowdown
If a template does not include those IDs, WebHaste simply never sends the search index to the visitor.
So you can leave search out of sites that do not need it (like a one-page landing page) without paying any performance cost.
Styling the search results (so it matches your site)
Search results are intentionally unstyled by default, so they can match whatever CSS framework you are using.
When results render, you’ll see markup like:
- A list: <ul className="cs-search-list">
- Each result: <li className="cs-search-item"> (one per matching page, with a link + short excerpt)
- Empty state: <p className="cs-search-empty"> (shown when nothing matches)
To style it, just add rules for those cs-* classes in your site’s CSS - the same way you’d style any other block or menu.
Keep pages out of search (or off your sitemap, or hidden from Google)
Sometimes you have pages you want to publish, but not advertise.
In WebHaste, click the gear icon next to any page to open Page Properties.
You’ll see three independent checkboxes:
- Exclude from sitemap.xml
- Leaves the page out of your generated sitemap.
- Exclude from site search
- Leaves the page out of search-index.json, so it will not show up in your on-site search.
- Hide from search engines (noindex)
- Adds a real <meta name="robots" content="noindex" /> tag to your page.
- This is the only setting that affects how Google and other search engines treat the page.
Important: even if you check any of these, the page still publishes normally. These settings only control discovery.
What kind of search is this (and what is it not)?
This is a basic keyword search designed for typical WebHaste sites - from a handful of pages up to around a hundred.
It is great for:
- Helping visitors quickly find the right page
- Documentation-style sites
- Small business sites with lots of service pages
It is not meant to be:
- A full search engine
- Advanced ranking and personalization
- Typo correction and fuzzy matching at scale
The upside is that it stays simple, fast, and private.
Upgrade and try it
If you’re on WebHaste v0.2.0+, you already have everything you need.
- If you’re using the official starter templates, search is likely already visible.
- If you’re using a custom template, add the two scripts + the two elements and you’re done.
Download WebHaste (free)
If you want the simplicity of static sites with a CMS-like workflow, WebHaste is a great fit.
Download the free extension: https://chromewebstore.google.com/detail/webhaste/ofblooflocfdegjjpgjfbefnjmjmbapa
Learn more: https://chromecms.com/
Next article
Need server-side functionality for a specific feature? Next, read: Workers & Cloud Functions: When You Need Server-Side (coming soon)