
Editorial illustration; the search interface and content cards are representative, not a live website.
On too many small websites, search is treated as a checkbox at the end of a build: drop a magnifying-glass icon in the header, wire it to a LIKE '%query%' SQL call or a default static search index, and ship it. Technically, it works. In practice, a visitor types a plain question, gets twelve vague links—half of them tag archives or old news posts—and gives up.
Good site search is less about fancy algorithms and more about answering one question: can a visitor find what they need even if they do not know your site’s internal terminology?
Start with the words visitors actually type
Before tweaking search weights or switching libraries, look at the language real people use when they are stuck. Check contact-form submissions, support emails, WhatsApp inquiries, and your existing search logs. Visitors rarely search for "Account Management Portal" or "Enterprise SLA"; they type "reset password", "lost invoice", or "cancel plan".
If your site runs a custom backend or static search, logging zero-result queries—even just the query string and result_count—is one of the fastest ways to spot gaps. When ten people search for "refund" and get zero hits because your page is titled "Billing Adjustments", you do not have a search-engine problem. You have a vocabulary and content problem. Either add the visitor’s phrasing to the page headings and summary, or create the missing destination page.
Get the HTML search form right
A search box should work cleanly with a keyboard, a screen reader, and even before heavy client-side JavaScript finishes hydrating. Wrap the form in a <search> landmark (or role="search"), give the input a real <label> (visually hidden only if the design truly demands it, though a visible label or button text is clearer), and use type="search":
<search>
<form action="/search/" method="get" role="search">
<label for="site-search">Search articles and guides</label>
<input id="site-search" name="q" type="search" placeholder="e.g. invoice, DNS, backup" required />
<button type="submit">Search</button>
</form>
</search>
Using method="get" with a ?q= query parameter means results URLs are bookmarkable, shareable, and work with the browser’s Back button. Avoid icon-only buttons with no accessible name, and never rely solely on placeholder text as the label—it vanishes the moment someone starts typing.
Make result cards explain why they matched
A list of bare page titles is rarely enough when three different pages mention the same topic. Each result should give the visitor enough context to choose without opening five tabs:
- Title and clear URL/category badge: helps distinguish a
/docs/guide from a/blog/opinion piece or a/pricing/page. - A focused excerpt: show the snippet around the matched term rather than the first 20 words of the article, which is often just intro fluff.
- Date only when freshness matters: showing
2021-04-12on an evergreen"How to reset 2FA"help doc makes people distrust a still-accurate answer; showing it on news or changelog posts helps.
If you control the indexer—whether that is PostgreSQL full-text search (setweight on title vs body), WordPress Relevanssi, or a static indexer like Pagefind—exclude repeated chrome. If your navigation menu and footer get indexed on every page, searching for "contact" or "support" returns every single page on the site with identical relevance. In Pagefind, for example, wrapping <header> and <footer> with data-pagefind-ignore (or indexing only <main data-pagefind-body>) immediately cleans up noisy results.
Handle the three states people hit
Most sites style the happy path (ten results found) and ignore the other three states:
- Empty query (
/search/with noq): Show a few common topics or example queries (Try "SSL", "pricing", or "WordPress") so visitors see what the search covers. - No results: Echo the query back clearly, state that nothing matched, and offer a concrete next step—links to top categories, a contact page, or a simpler query tip. Never silently rewrite the user’s query behind their back or render a blank white space.
- Weak or broad matches: If your engine falls back to fuzzy or partial matching, label it honestly (“Showing broad matches for…”) instead of pretending an unrelated page is an exact hit.
Test with real language, not page titles
Testing search by typing the exact title of your homepage is useless. Keep a five-query smoke test you run after every major content or template change:
- An exact page title (should rank #1).
- A common synonym that does not appear in the title (e.g.
"bill"instead of"invoice"). - A plain-language question (
"how to change email"). - A realistic typo or alternate spelling (
"refurbish"vs"refurbished"). - Gibberish or an out-of-scope term (must trigger the no-results state cleanly).
Run those five checks on a phone while logged out, using only keyboard navigation (Tab, Enter, and Back). Also audit old URLs: nothing kills trust in site search faster than clicking the top result and landing on a 404.
Search is a safety net and a shortcut, not an excuse for confusing navigation. When your pages have clear headings, honest excerpts, and clean URLs, even a modest search implementation feels fast and dependable.
For related guides on keeping small web projects maintainable, see:
- A Project Handoff Checklist That Lets the Next Person Actually Run the Work
- How to Build a Software Inventory You Can Actually Maintain
- How to Build an Incident Timeline for a Small Web Project