September 22, 2024 8.05PM

Replaced my previous hand rolled site search that brute-forced an ungainly blob of JSON.

Opted for pagefind as I knew I wanted to stick with static search that I can compile at build time. Will tweak styles later but you can see it working already at the search page.

Much faster and more robust.

By default it grabs the title from the first <h1> on the page which strikes me as odd. Not all my pages β€” like those I call nonsense β€” have a <h1>. Workaround: added one of its data attributes to the title element in my document head template and set the result icon to my site favicon for all pages that have no images:

<head>
    {% block head -%}
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="generator" content="The humble hands of Silas" />
    <meta data-pagefind-default-meta="image[content]" content="/favicon.png" />
<title data-pagefind-meta="title">
    {%- block title -%}
        {% if page -%}
            {{ page.title -}}
Added dependency:    pagefind
Removed dependency:  my terrible javascript skills

Monday, 19th November 2024 20:44:22-08:00

Added the data-pagefind-ignore attribute to collections so that collection pages don’t rank in search results.

<section data-pagefind-ignore class="collection-section">
{% for item in items %}
<article class="collection {{ style }}">