Skip to content

Address review feedback on site search - #3

Merged
notleowang merged 7 commits into
site-searchfrom
site-search-review-fixes
Nov 24, 2026
Merged

notleowang merged 7 commits into
site-searchfrom
site-search-review-fixes

Conversation

@notleowang

@notleowang notleowang commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Changes for the review from @stockholmux on valkey-io#723, to be merged into site-search.

I will attempt to write my findings and describe the changes through comments under this PR.

Review items

  • 1. The search button is easy to miss (compact trigger, grey-on-grey) (measurements)
  • 2. Search analytics (hits and misses), or a way to add them
  • 3. Contrast of the grey-on-grey and light text (measurements)
  • 4. A search page, or a way to start a search from the URL
  • 5. Closing search scrolls the page to the top (changes)
  • 6. Boosting topics in results, and leaving topics out of the index

Other

  • 7. Keeping design, templates, content and code separate

Inline-code items

Each item's changes are described in a comment, linked from the list above.

Note

The failing assign-reviewers check is expected on this PR. It comes from upstream's Assign blog reviewers workflow, which runs because item 10 changes content/blog/_index.md. It needs the Valkeyrie Bot app's secrets, which only valkey-io/valkey-io.github.io has, so in this fork it fails at "Generate token" (Input required and not supplied: app-id). Upstream on valkey-io#723 it has the secrets and skips, since no blog post is added.

Project Scope

Upon looking at the requested changes, I have certain opinions on what can be addressed immediately without deviating out of scope or making big behavioral changes.

Item Immediately addressable? Comments
1. The search button is easy to miss (compact trigger, grey-on-grey) Y The stylistic decisions were built on valkey.io's existing style properties so changing the colors could introduce inconsistency with the valkey brand?
2. Search analytics (hits and misses), or a way to add them N Feels broader in scope than the initial PR
3. Contrast of the grey-on-grey and light text Y See 1.
4. A search page, or a way to start a search from the URL N Feels broader in scope than the initial PR
5. Closing search scrolls the page to the top Y Implemented
6. Boosting topics in results, and leaving topics out of the index N May be difficult to address... Requires likely tuning Pagefind internals
7. Keeping design, templates, content and code separate Y Will be a factor to consider while making changes.
8. Result template as HTML in a JS string Y Implemented
9. Breadcrumbs don't match the docs breadcrumbs Y Implemented
10. Breadcrumbs from template logic rather than data or front matter Y Implemented

Check List

  • Commits are signed per the DCO using --signoff

Topic and command pages show breadcrumbs from the documentation menu
(nav.yml) since valkey-io#707, but search results gave them a breadcrumb made from
the URL and the command's group, such as "Documentation › Command
Reference › Server" for BGSAVE, whose page shows "Topics ›
Administration › Persistence". Both now come from the page's place in the
menu, so a result's breadcrumb is the page's own without the page itself.

Signed-off-by: notleowang <leo.wang@improving.com>
@notleowang

Copy link
Copy Markdown
Collaborator Author

9. Breadcrumbs from the docs menu

Commit: 0483680

Search breadcrumbs didn't match the docs breadcrumbs, which come from the documentation menu (nav.yml) since valkey-io#707.

Topic and command pages already work out their place in the menu (nav_location) for their own breadcrumbs. They now also set search_breadcrumb from it, which default.html uses in place of the URL-based breadcrumb. A result's breadcrumb is the page's own breadcrumb without the page itself:

Page Before After
/topics/lists/ Documentation › Documentation by Topic Topics › Data types
/commands/lpush/ Documentation › Command Reference › List Topics › Data types › Lists
/commands/bgsave/ Documentation › Command Reference › Server Topics › Administration › Persistence
/commands/json.set/ Documentation › Command Reference › JSON Topics › Data types › Valkey JSON

Commands that aren't in the menu fall back to Commands, as on their pages. The groups.json lookup in command-page.html is no longer needed and is removed. The other sections and the /topics/ and /commands/ index pages still use the URL-based breadcrumbs, which item 10 covers.

Tested with a local build (Zola 0.23.6, Pagefind 1.6.0, current valkey-doc, valkey and modules): on all 87 topic pages and 459 command pages, the search breadcrumb equals the page's breadcrumb without its last item, and build/check-search-index.py reports 791 pages indexed with 0 problems.

@notleowang

notleowang commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

9a. - Previews

Commit: 0483680

After (hosted locally via zola 0.23.6 and pagefind 1.6.0):
image

Before (from Preview https://pr-723--valkey-preview.netlify.app/)
image

@notleowang notleowang self-assigned this Nov 20, 2026
Breadcrumbs for pages other than topics and commands came from a list of
URL paths and labels in default.html, so adding a section or changing a
breadcrumb meant changing template logic. Each section now sets its
breadcrumb with `breadcrumb` in its [extra] front matter, and a page uses
its own, or else the one of its nearest section that sets one.

Every page's breadcrumb is unchanged.

Signed-off-by: notleowang <leo.wang@improving.com>
The topic and command pages' search breadcrumbs start with "Topics", or
"Commands" for commands that aren't in the docs menu, but the indexes
themselves had "Documentation › Documentation by Topic" and
"Documentation › Command Reference". They now have "Topics" and
"Commands".

Signed-off-by: notleowang <leo.wang@improving.com>
@notleowang

Copy link
Copy Markdown
Collaborator Author

10. Breadcrumbs from front matter instead of template logic

Commits: be3e179, 5c49075

Breadcrumbs for pages other than topics and commands came from a list of URL paths and labels in default.html. Each section now sets its breadcrumb in its front matter:

[extra]
breadcrumb = "Blog"

A page uses its own extra.breadcrumb, or else the one of its nearest section that sets one (found through page.ancestors). Topic and command pages still take theirs from the docs menu (item 9). default.html no longer has any section names or labels, so adding a section or changing a breadcrumb is a front matter change.

Front matter Breadcrumb
blog/_index.md Blog
authors/_index.md Blog › Authors
community/_index.md, events/_index.md Community
try-valkey/_index.md Try Valkey
download/index.md, download/releases/_index.md, download/versions/_index.md Download
clients/_index.md Documentation › Clients
integrations/_index.md Documentation › Integrations
docs/index.md Documentation
participants.md Participants
topics/_index.md Topics
commands/_index.md Commands

The second commit changes the breadcrumbs of the topic and command indexes from "Documentation › Documentation by Topic" and "Documentation › Command Reference" to "Topics" and "Commands", the same as the start of their pages' breadcrumbs.

Testing

Built locally with Zola 0.23.6 and Pagefind 1.6.0, comparing every page's search breadcrumb between builds:

  • be3e179 against 0483680: 0 differences across 825 pages.
  • 5c49075 against be3e179: 2 differences, /topics/ and /commands/, as intended.
  • build/check-search-index.py: 791 pages indexed, 0 problems.

Signed-off-by: notleowang <leo.wang@improving.com>
The release automation (update-valkey-website.yml in
valkey-io/valkey-release-automation) rewrites content/try-valkey/_index.md
from a fixed template on every Valkey release, which would drop its
`breadcrumb` and leave the Try Valkey pages without one.

Pages with no `breadcrumb` in their own or their sections' front matter
now use the title of their nearest section other than the site's root.
Try Valkey's section title is its breadcrumb, so its `breadcrumb` is
removed and the file is again exactly what the automation writes. The
automation isn't changed.

Every page's breadcrumb is unchanged.

Signed-off-by: notleowang <leo.wang@improving.com>
@notleowang

notleowang commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

10. Follow-up: section title fallback for the release automation

Commits: 5c6ca14 (merge of site-search), 68e285f

Problem found:

The release automation (update-valkey-website.yml in valkey-io/valkey-release-automation) rewrites content/try-valkey/_index.md from a fixed template on every Valkey release.

So the breadcrumb field added in the Frontmatter implementation in be3e179 would be dropped at the next release, leaving the Try Valkey pages without a breadcrumb.

Current workaround:

Pages with no breadcrumb in their own or their sections' front matter now use the title of their nearest section other than the site's root. Try Valkey's section title is "Try Valkey", so its breadcrumb is removed and the file is again exactly what the automation writes. The release automation isn't changed.

The automation's other step adds a new content/download/releases/v<version>.md per release and doesn't touch download/releases/_index.md, so release pages keep inheriting "Download" (as v9.2.0 does).

Testing

The modal's contents and Pagefind's result template were HTML strings in
search.js. They're now in templates/includes/search-modal.html, in a
<template> next to the search button's slot in default.html, which
search.js copies into the modal. A <template> keeps the Pagefind
elements inactive until they're in the modal, as the string-built one
did. It's outside .body, so Pagefind doesn't index it.

The result template is wrapped in {% raw %} ... {% endraw %}, which makes
Zola output its contents as written instead of rendering them. Pagefind's
placeholders ({{ meta.title }}, {{#if excerpt}}, {{+ excerpt +}}) use the
same braces as Zola's templates, so without it Zola would try to evaluate
them at build time and fail. No other template needs this; the only
other use in the repo is the 2024-11-21-testing-the-limits blog post,
which uses it to show Docker's {{.Names}} format string.

The modal's markup is unchanged.

Signed-off-by: notleowang <leo.wang@improving.com>
@notleowang

Copy link
Copy Markdown
Collaborator Author

8. Search modal markup in a template instead of a JS string

Commit: c9e9d97

The modal's contents and Pagefind's result template were HTML strings in search.js (createModal()'s innerHTML and RESULT_TEMPLATE). They're now in a Zola template, templates/includes/search-modal.html, included in default.html next to the search button's slot:

<div id="site-search"></div>
{% include "includes/search-modal.html" %}

It's a <template id="search-modal-contents">, which search.js copies into the <pagefind-modal>. search.js now has only behaviour, and editing the result layout is an HTML change.

  • Why a <template>: its contents aren't active, so the Pagefind elements don't initialize until the modal has moved them into its dialog. This is the same reason the old code built a <template> in JS.
  • Why not a separate file fetched at runtime: that would add a request when search opens, and another way for search to fail.
  • Indexing: it's outside .body, the part of the page Pagefind indexes (root_selector in pagefind.yml), so its markup isn't indexed.

About {% raw %}

The result template is wrapped in {% raw %} … {% endraw %}, which makes Zola output its contents as written instead of rendering them. Pagefind's placeholders ({{ meta.title }}, {{#if excerpt}}, {{+ excerpt +}}) use the same braces as Zola's templates, so without it Zola would try to evaluate them at build time and fail. The JS string never needed this because Zola copies static/ files without processing them.

No other template uses raw. The only other use in the repo is the 2024-11-21-testing-the-limits blog post, which uses it to show Docker's {{.Names}} format string.

Testing

  • The rendered <template> matches the old JS markup with whitespace ignored, so the modal's markup is unchanged.
  • One template per page, inside the header <nav> and outside .body.
  • build/check-search-index.py: 795 pages indexed, 0 problems. Every page's search breadcrumb is unchanged.
  • Checked locally in the browser: results, breadcrumbs and section links display as before, with a single search input, and opening and closing work on desktop and in the mobile menu.

@notleowang
notleowang marked this pull request as ready for review November 23, 2026 21:47
Closing search from further down a page scrolled back to the top. When
the modal closes, Pagefind's modal trigger (handleModalClose in
pagefind-modal-trigger.ts, the same in Pagefind 1.6.0 and its main
branch) focuses the search button, and focusing it scrolls it into view.
The header isn't sticky, so the button is at the top of the page.

It only jumped when the button didn't already have focus, such as the
first time search was closed after loading the page or after clicking in
the page. Otherwise, the dialog returns focus to the button when it
closes, which doesn't scroll, and Pagefind's focus does nothing.

search.js now wraps the trigger's close handler and makes its focus not
scroll. Pagefind's handler still runs, so focus still returns to the
search button.

Signed-off-by: notleowang <leo.wang@improving.com>
@notleowang

notleowang commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

5. Closing search no longer scrolls to the top

Commit: c11d3c8

Cause

When the modal closes, Pagefind's modal trigger focuses the search button (handleModalClose in pagefind-modal-trigger.ts):

handleModalClose(): void {
  if (this.buttonEl) {
    this.buttonEl.setAttribute("aria-expanded", "false");
    this.buttonEl.focus();
  }
}

focus() scrolls the button into view. The header isn't sticky (position: relative), so from further down a page, closing search jumped back to the top. This is the same in Pagefind 1.6.0, the latest release, and on its main branch.

It only jumped when the button didn't already have focus: the first time search was closed after loading the page, or after clicking in the page. Otherwise, the dialog itself returns focus to the button when it closes, which by the HTML spec doesn't scroll, and Pagefind's focus() then does nothing.

Fix

search.js wraps the trigger's close handler, the same way it already wraps Pagefind's search for exact title matches. While Pagefind's handler runs, the button's focus() is called with preventScroll: true. Everything else is Pagefind's own handler, so focus still returns to the search button and aria-expanded is still reset. If a future Pagefind version renames the handler, the wrapper does nothing.

Removing this patch

This is a workaround for Pagefind's behaviour, not something the site needs to keep. If Pagefind's handleModalClose uses focus({ preventScroll: true }), or otherwise stops scrolling to the button on close, keepScrollPositionOnClose and its call in search.js can be deleted after upgrading to that version. This would need an issue or PR on Pagefind; none has been opened yet.

To check after an upgrade: remove the wrapper, scroll down a long page, click in the page text, then open search with Cmd-K and close it with Esc. If the page stays where it was, the patch is no longer needed.

Testing

  • Checked locally in the browser, after scrolling down a long page: closing with Esc, the close button and by clicking outside all keep the scroll position, including after clicking in the page first. Tab continues from the search button after closing, results still open their pages, and search still works from the mobile menu.
  • The wrapper, run in JavaScriptCore against a stand-in for Pagefind's trigger: Pagefind's handler runs, focus gets preventScroll: true, aria-expanded is reset, and the temporary focus is removed afterwards.
  • build/check-search-index.py: 795 pages indexed, 0 problems.

@notleowang

Copy link
Copy Markdown
Collaborator Author

1 and 3. Search button visibility and contrast: current measurements

No changes yet. These are the current colours and contrast ratios of the search UI, to decide what to change.

Method: computed styles from a built page (/commands/client-list/) in headless Chrome at 1440px wide, with Pagefind's CSS and ours applied. Pagefind's search doesn't finish headless, so the results were measured on one row rendered from the site's own result template, which gets the same CSS as a real result. Thresholds are WCAG 2.2 AA: 4.5:1 for normal text (nothing here is large text), and 3:1 for non-text parts needed to identify a control (1.4.11). Hover and pressed states weren't measured.

Search button in the header

Part Colours Ratio Needs
Magnifying glass icon #767676 on #f8f9fa 4.31:1 3:1 ✅
⌘ K key text (11px) #666 on #f5f5f5 5.27:1 4.5:1 ✅
⌘ K key outlines #dfe1e4 on #f8f9fa 1.24:1 — very faint
Button fill against the header #f8f9fa on #fff 1.05:1 — practically invisible
Button border against the header #dfe1e4 on #fff 1.31:1 — very faint

In compact mode the button has no visible text: only a 14×14px icon and the ⌘ K keys, with "search" as an aria-label. It passes because the icon alone meets 3:1, but its fill and border barely differ from the white header. The GitHub button it's styled to match has the same fill and border (1.31:1), but reads as a button because of its text, "GitHub" in #444 at 16px (9.24:1).

Modal and results

Part Colours Size Ratio
Input placeholder #767676 on #fff 16px 4.54:1 ✅ (by 0.04)
Summary ("N results for…") #767676 on #fff 12px 4.54:1 ✅ (by 0.04)
Result breadcrumb #666 on #fff 13px 5.74:1 ✅
Result excerpt #666 on #fff 13px 5.74:1 ✅
Section excerpt #666 on #fff 12px 5.74:1 ✅
Footer key hints (↓ ↑ esc) #666 on #f5f5f5 10px 5.27:1 ✅
Close button #666 on #fff 13px 5.74:1 ✅
Titles, section links, typed text #1a1a1a on #fff 12–16px 17.4:1 ✅
Highlighted matches (<mark>) #1a1a1a on #fff 12–13px 17.4:1 ✅
Result card border #e0e0e0 on #fff — 1.32:1 decorative
Focus outline #0969da on #fff 2px ~5.2:1 ✅

Possible concerns

  1. No visible label on the search button. This is the main reason it's easy to miss: grey icon and keys on a fill and border that barely stand out.
  2. Pagefind's lightest grey has no margin. #767676 is about the lightest grey that passes 4.5:1 on white. It's used for the placeholder and summary. On the button's #f8f9fa it's 4.31:1: fine for the icon, but a "Search" label in that colour would fail. So adding a label (item 1) also needs a darker colour (item 3).
  3. Small text. Footer hints are 10px, the ⌘ K keys 11px, and the summary and section excerpts 12px. WCAG has no minimum size, but small mid-grey text is what makes it feel faint.
  4. Matches stand out only by weight. Highlighted matches are the same colour as the text around them, only slightly bolder (500 vs 400).
  5. Not search, but nearby: the header's nav links ("Download", "Documentation", …) are #6983ff on white at 16px, 3.34:1, below 4.5:1. That's existing site styling, outside this PR.

@notleowang
notleowang requested review from danielfrankcom and removed request for danielfrankcom November 24, 2026 00:29
@notleowang
notleowang merged commit e7a70ce into site-search Nov 24, 2026
1 check failed
@notleowang

Copy link
Copy Markdown
Collaborator Author

Continuing this thread in another PR. #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant