Skip to content

feat(pages): let a page's head set or skip titleTemplate - #906

Merged
Brooooooklyn merged 1 commit into
mainfrom
feat/page-title-template
Nov 24, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
feat/page-title-template

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Closes #903.

A page whose title already names the site got the suffix twice:

config:  titleTemplate: '%s | My App'
page:    title: 'My App | Q&A'
before:  <title>My App | Q&A | My App</title>
after:   page returns titleTemplate: ''  →  <title>My App | Q&A</title>

Change

template = page.titleTemplate ?? middleware.titleTemplate ?? config.titleTemplate
  • '' drops the template (same rule middleware headDefaults already documents). '%s' also works.
  • Any other string replaces it for that page.
  • defineHead returns HeadConfig (= HeadDescriptor + titleTemplate), so the field type-checks.
  • The template is never sent to the client; only the final title is.

I kept the opt-out as '' rather than adding false/null, so config, middleware and pages share one rule and type.

Tests

  • pages-head.test.ts: page template wins, ''/'%s' skip, page template wraps a lower-layer title, fallback when unset, template not emitted.
  • routing-runtime.test.ts: full page handler with defineHead + middleware + config.
  • New tests fail on main, pass here. vp check and vp run test pass.

Docs

head.md (new "Page title templates" section, precedence table), handlers.md signature, types.md (new HeadConfig entry), config.md table row.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T14:38:31.263452Z c3d1a11 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-page-title-template-void-cloud.voidzero-docs.workers.dev (commit 15b7ba8)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://38a0f3de-void-cloud.voidzero-docs.workers.dev 15b7ba8 2026-11-24T03:39:04.662Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a21def6c-void-cloud.voidzero-docs.workers.dev c3d1a11 2026-11-23T14:38:44.226Z Visit the dashboard ↗

A page's `head()` can now return `titleTemplate`. It wins over the
middleware `headDefaults` template and the config template, as the page's
`title` already does. An empty string drops the template, the same rule
middleware follows. `defineHead` now returns `HeadConfig`.

Closes #903.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn force-pushed the feat/page-title-template branch from c3d1a11 to 15b7ba8 Compare November 24, 2026 03:37
@Brooooooklyn
Brooooooklyn merged commit 8e86066 into main Nov 24, 2026
25 of 27 checks passed
@Brooooooklyn
Brooooooklyn deleted the feat/page-title-template branch November 24, 2026 03:50
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.

Let a page's head set or skip titleTemplate

1 participant