Repository navigation
fix: update the description tags upon client-side navigation (vikejs/vike#3524) - #231
Merged
Merged
Conversation
…/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
This was referenced Sep 25, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements vikejs/vike#3524:
+descriptionnow updates upon client-side navigation, the same way+titledoes.Problem
+descriptiononly 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 usesog:descriptionwhen saving a pin.Change
descriptionis now a client-side setting (env: { server: true, client: true }, liketitleandlang). Upon client-side navigation,onRenderClient()applies it:applyHeadSettings()updates<meta name="description">and<meta property="og:description">, and creates them if they're missing.title(see the comment inapplyHeadSettings.tsx):undefined: the tags are left untouched (they may have been set by+Head)nullor'': the tags are removed (the server-side doesn't render them either)useConfig({ description })/<Config description>works upon client-side navigation too:title, with the same precedence (fix: let useConfig() inside UI components take precedence upon client-side navigation (vikejs/vike#3525) #230).+data():descriptionis added toconfigsClientSide, so it's kept inpageContext._configViaHookand sent to the client, including in prerendered*.pageContext.jsonfiles (useConfig({ title }) in +data loses title on prerendered client navigation vike-vue#233).+descriptionfunction now receivesPageContextinstead ofPageContextServer(like+title), since it's also called on the client-side.Also:
og:title(separate commit)+titlerenders<title>and<meta property="og:title">, but upon client-side navigation onlydocument.titlewas updated. Nowog:titleis updated too, so all the tags rendered by+titleand+descriptionmatch the current page. Otherwiseog:descriptionwould be up to date whileog:titlestill showed the first page. It's a separate commit (20ec7d4) in case you'd rather drop it.Minor breaking change
+descriptionis now also loaded and called in the browser, like+title. So a+descriptionfunction that readspageContextproperties that aren't sent to the client (https://vike.dev/passToClient), or a+description.jsfile that imports server-only code, needs to be updated. Maybe worth aMINOR BREAKING CHANGESnote.Tests (
examples/full)description update client-side page navigation. It navigates/→/without-ssr→/star-wars→/images→/without-ssrand checks<meta name="description">and<meta property="og:description">after each step. That covers a description set:+description(new, on/without-ssr),useConfig()inside+data()(/star-wars),<Config description>inside a UI component (new, on/images).The last step checks that the description of
/imagesdoesn't leak to the next page.useConfig() HTMLchecks the description set by<Config description>in the HTML.expectTitle()now also checksog:title. It's used by the title tests, which cover both hydration and client-side navigation.description update client-side page navigationfails withexpected null to equal 'Page rendered only in the browser'.og:titlecommit,title update client-side page navigationfails withexpected 'My Vike + React App' to equal '6 Star Wars Movies'.test:types,test:unitsandformat:check.Related PRs
+descriptionupdates upon client-side navigation (#3524) vike#3527: docs🤖 Generated with Claude Code
https://claude.ai/code/session_019AAZpDLjrcSr6BwQgpVs9a