Forma

Built-in site search with one shortcode

Add fast, progressively enhanced search to any Forma page with [[search]], SQLite FTS5, and customizable result templates.

Search is one of those features that becomes complicated because platforms make it complicated. A small content site should not need a hosted search subscription, a JavaScript application, and a nightly indexing pipeline just to find a page.

Forma keeps the whole feature inside the same portable SQLite database as the content.

Add search to a page

Insert the built-in snippet wherever the search interface should appear:

[[search]]

That can live on a dedicated Search page, inside documentation, or in a utility area of your layout. The snippet renders the form and results container. The public endpoint is /search?q=your+words.

With JavaScript available, htmx requests the result fragment and swaps it into the page. Without JavaScript, the form submits normally and Forma renders a complete results page. The URL is shareable in both cases.

That is progressive enhancement in the useful sense: JavaScript improves the interaction, but it is not a requirement for the feature to exist.

What Forma indexes

The search index includes public content people can actually visit:

  • pages;
  • published blog posts;
  • public podcast episodes.

Internal templates and reusable snippets are not search results. Draft or future-dated posts remain private and do not leak through search.

Whenever you save or delete content, Forma updates the matching search document. A full HTML-cache rebuild also reindexes the site, so migrations and major content changes have an easy repair path.

FTS5 when available, LIKE when it is not

On hosts with SQLite FTS5, Forma uses a Unicode-aware full-text index. That gives fast matching and sensible ranking without another service. Titles carry strong relevance because the content is indexed as structured documents rather than one unlabelled blob.

Some shared hosts compile SQLite without FTS5. Forma detects that condition and creates a plain search table instead. Queries then use LIKE matching. It is less sophisticated, but the feature continues to work.

You can see the active engine under Settings → Cache → HTML cache and in Hosting Check. There is no mystery dependency that silently breaks the search box.

Customize the display

Forma seeds two internal templates:

  • search-page controls the complete page response;
  • search-results controls the result list or htmx fragment.

Edit those templates like any other Forma template. A result includes the document type, title, URL, date label, and a text excerpt, so you can build a compact command-palette style list or a more editorial card layout.

A simple result treatment might show:

  1. the title as the main link;
  2. a small Page, Post, or Episode badge;
  3. the excerpt with matching context;
  4. the publish date where it adds value.

Keep the search page itself out of the index. Forma marks search responses noindex and excludes its internal templates from the sitemap, preventing endless query URLs from becoming search-engine landing pages.

Search and HTML cache work together

HTML cache does not make the site less dynamic. Published pages are files; search remains a PHP question. A visitor can land on a static documentation page, type a query, and receive live results from SQLite.

That boundary is the point. Cache stable answers aggressively. Keep genuinely variable behavior dynamic. Forma gives you both without turning the site into a single-page application.