Skip to content

Commit e857a8e

Browse files
committed
feat(layout): add canonical link and update og:url to use sanitized path
Introduces a canonical url derived from the origin and pathname to prevent duplicate content indexing. updates the open graph metadata to use this sanitized url, ensuring search engines and social platforms point to the authoritative version of the page.
1 parent 6b5664b commit e857a8e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

projects/client/src/lib/sections/layout/TraktPage.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
: _info,
7474
);
7575
76+
const canonicalUrl = $derived(
77+
`${page.url.origin}${page.url.pathname}`,
78+
);
79+
7680
const dynamicContentProps = $derived(
7781
hasDynamicContent
7882
? {
@@ -84,9 +88,10 @@
8488

8589
<svelte:head>
8690
<title>{displayTitle}</title>
91+
<link rel="canonical" href={canonicalUrl} />
8792
<meta property="og:site_name" content={websiteName} />
8893
<meta property="og:type" content={ogType} />
89-
<meta property="og:url" content={page.url.toString()} />
94+
<meta property="og:url" content={canonicalUrl} />
9095
<meta property="og:image" content={image} />
9196
<meta property="og:title" content={ogTitle} />
9297
<meta property="og:locale" content="en_US" />

0 commit comments

Comments
 (0)