fix: use page.data for dynamic SEO meta tags instead of duplicating t… - #3411
fix: use page.data for dynamic SEO meta tags instead of duplicating t…#3411Adarshkumar0509 wants to merge 2 commits into
Conversation
…hem per page Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
3d14b52 to
b8acbbc
Compare
|
This will duplicate the description field. In order to fix that, you need to address the issue with the metadata field being duplicated across the codebase. ProblemRoute components currently repeat the same What to do about it?Replace the fixed social-only implementation in type PageMetadata = {
title: string;
description: string;
keywords: string;
canonicalUrl: string;
type?: "website" | "article";
imageUrl?: string;
};The component must render the title, canonical link, description, keywords, Each Each <Metadata metadata={data.metadata} />Structured data that is unique to a page, such as the home page's JSON-LD, Required changesMigrate the remaining route heads to the same component:
Dynamic URLs must be assembled at prerender time from trusted route parameters The Validation
|
Description
This PR fixes the duplicate SEO meta tag issue that was causing problems with SSR and social media scrapers.
Previously, each page was managing its own meta tags inside svelte:head, which led to duplicate og:title, og:description, twitter:title etc. showing up in the raw HTML. Social platforms like Twitter and LinkedIn are picky about this and would pick up the wrong tag.
What I did:
Moved all dynamic meta tags into metadata.svelte it now reads title, description, url, and ogType from $page.data with sensible fallbacks to the layout's translation keys
Updated news/[slug]/+page.server.ts to return these values from the load function so the layout picks them up automatically
Removed the svelte:head block from news/[slug]/+page.svelte since the layout now handles everything no more duplicates
This is the approach sydseter suggested in the comments on #2946.
Resolves: #2194
AI Tool Disclosure
[e.g. GitHub CoPilot, ChatGPT, JetBrains Junie etc.][e.g. GPT-4.1, Claude Haiku 4.5, Gemini 2.5 Pro etc.][Summarize the key prompts or instructions given to the AI tools]Affirmation