Skip to content

Give every page a unique title derived from its h1 - #63

Merged
lexler merged 2 commits into
mainfrom
fix/36-unique-page-titles
Oct 30, 2026
Merged

lexler merged 2 commits into
mainfrom
fix/36-unique-page-titles

Conversation

@lexler

@lexler lexler commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Fixes #36.

Every page used to share the <title> "Augmented Coding Patterns". Each page's title is now its h1 plus " | Augmented Coding Patterns". The home page keeps the site name on its own.

How

  • The root layout sets title: { default: siteConfig.name, template: '%s | Augmented Coding Patterns' }.
  • Each route takes its title from the same value its h1 shows:
    • pattern detail: pattern.title (alternative-title redirect slugs resolve to the canonical pattern)
    • category list: labelPlural from getCategoryConfig
    • contributor detail: contributor.name
    • contributors, pattern catalog, talk: fixed titles stored in a constant that the h1 also uses
  • Pattern lookup (by canonical slug or alternative-title slug) is pulled out of PatternPage into resolvePattern, so generateMetadata and the page share it. Behaviour is unchanged.

Tests

  • 9 "Page titles" unit tests in tests/unit/components/pages.test.tsx, written first and seen failing: each page's title value, the layout template (checked once), and the redirect page having no inline <title>.
  • 1 Playwright smoke test: the <title> of /anti-patterns/answer-injection/ equals its h1 plus the site suffix.
  • ./test.sh (latest run on 892310e): 22 suites, 379 tests pass. npm run lint: 0 errors, 0 warnings.
  • ./e2e.sh (latest run): 89 passed, 4 failed, 9 skipped. All 4 failures are iPhone/WebKit search tests from the pre-hydration bug fixed in Keep search text typed before the page finishes loading #64, which this branch doesn't include. Desktop and Android pass, including the new title smoke test. How many iPhone search tests fail varies between runs (4 to 6 so far).

Redirect pages

Alternative-title redirect pages used to render an empty <title></title> from inline JSX next to the metadata title. The inline title is gone, so they now have exactly one title, the canonical pattern's (e.g. Approved Scenarios | Augmented Coding Patterns). A unit test covers this.

Title tests

The tests check each page's title value and check the layout template once, instead of reimplementing Next's template.

ampagent and others added 2 commits October 30, 2026 05:07
Each route with an h1 now exports metadata whose title is the same value
the h1 shows; the root layout wraps it as "<h1> | Augmented Coding Patterns".
The home page keeps the bare site name.

Fixes #36

Amp-Thread-ID: https://ampcode.com/threads/T-01a18b16-89b6-7301-9d0c-e6ff7f681d32
Co-authored-by: Lada Kesseler <archie.kesseler@gmail.com>
The inline <title> rendered empty and duplicated the metadata title.
Title tests now assert each page's title value and the layout template
once instead of reimplementing Next's template.

Amp-Thread-ID: https://ampcode.com/threads/T-01a18b16-89b6-7301-9d0c-e6ff7f681d32
Co-authored-by: Lada Kesseler <archie.kesseler@gmail.com>
@lexler
lexler merged commit c77ad6c into main Oct 30, 2026
4 checks passed
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.

Every page has the same <title>

2 participants