Skip to content

fix: update the description tags upon client-side navigation (vikejs/vike#3524) - #231

Merged
brillout merged 2 commits into
mainfrom
claude/gracious-goodall-phumbx
Sep 25, 2026
Merged

brillout merged 2 commits into
mainfrom
claude/gracious-goodall-phumbx

Conversation

@brillout

@brillout brillout commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Implements vikejs/vike#3524: +description now updates upon client-side navigation, the same way +title does.

Problem

+description only rendered <meta name="description"> and <meta property="og:description"> into the HTML of the first page. Upon client-side navigation, the tags kept the description of the first page. That's fine for crawlers (they read the HTML), but some tools read the tags from the DOM of the page the user is currently viewing. For example, the Pinterest browser extension uses og:description when saving a pin.

Change

  • description is now a client-side setting (env: { server: true, client: true }, like title and lang). Upon client-side navigation, onRenderClient() applies it: applyHeadSettings() updates <meta name="description"> and <meta property="og:description">, and creates them if they're missing.
  • Same semantics as title (see the comment in applyHeadSettings.tsx):
    • undefined: the tags are left untouched (they may have been set by +Head)
    • null or '': the tags are removed (the server-side doesn't render them either)
  • useConfig({ description }) / <Config description> works upon client-side navigation too:
  • Types: a +description function now receives PageContext instead of PageContextServer (like +title), since it's also called on the client-side.

Also: og:title (separate commit)

+title renders <title> and <meta property="og:title">, but upon client-side navigation only document.title was updated. Now og:title is updated too, so all the tags rendered by +title and +description match the current page. Otherwise og:description would be up to date while og:title still showed the first page. It's a separate commit (20ec7d4) in case you'd rather drop it.

Minor breaking change

+description is now also loaded and called in the browser, like +title. So a +description function that reads pageContext properties that aren't sent to the client (https://vike.dev/passToClient), or a +description.js file that imports server-only code, needs to be updated. Maybe worth a MINOR BREAKING CHANGES note.

Tests (examples/full)

  • New test description update client-side page navigation. It navigates / → /without-ssr → /star-wars → /images → /without-ssr and checks <meta name="description"> and <meta property="og:description"> after each step. That covers a description set:
    • by +description (new, on /without-ssr),
    • by useConfig() inside +data() (/star-wars),
    • by <Config description> inside a UI component (new, on /images).
      The last step checks that the description of /images doesn't leak to the next page.
  • useConfig() HTML checks the description set by <Config description> in the HTML.
  • expectTitle() now also checks og:title. It's used by the title tests, which cover both hydration and client-side navigation.
  • I checked that the new assertions fail without the fix:
    • Without the first commit, description update client-side page navigation fails with expected null to equal 'Page rendered only in the browser'.
    • Without the og:title commit, title update client-side page navigation fails with expected 'My Vike + React App' to equal '6 Star Wars Movies'.
  • Locally, all e2e tests pass (all examples, dev and preview), as do test:types, test:units and format:check.

Related PRs

🤖 Generated with Claude Code

https://claude.ai/code/session_019AAZpDLjrcSr6BwQgpVs9a

…/vike#3524)

The +description setting (and useConfig({ description })) now also updates
<meta name="description"> and <meta property="og:description"> upon
client-side navigation, the same way +title updates document.title. Some
tools read these tags from the DOM of the current page, e.g. browser
extensions for bookmarking and social sharing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AAZpDLjrcSr6BwQgpVs9a
+title renders <title> and <meta property="og:title">, but upon client-side
navigation only document.title was updated. Also update og:title, so that
all tags rendered by +title and +description reflect the current page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AAZpDLjrcSr6BwQgpVs9a
@brillout brillout changed the title feat: update the description tags upon client-side navigation (vikejs/vike#3524) fix: update the description tags upon client-side navigation (vikejs/vike#3524) Sep 25, 2026
@brillout
brillout merged commit 6e89374 into main Sep 25, 2026
7 checks passed
@brillout
brillout deleted the claude/gracious-goodall-phumbx branch September 25, 2026 20:05
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.

2 participants