Skip to content

Commit 35eae1a

Browse files
authored
Fix canonical in a safe way (#2589)
1 parent e85d357 commit 35eae1a

File tree

1 file changed

+2
-1
lines changed
  • packages/gitbook/src/app/(site)/(content)/[[...pathname]]

1 file changed

+2
-1
lines changed

packages/gitbook/src/app/(site)/(content)/[[...pathname]]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export async function generateMetadata({
150150
.join(' | '),
151151
description: page.description ?? '',
152152
alternates: {
153-
canonical: absoluteHref(getPagePath(pages, page), true),
153+
// Trim trailing slashes in canonical URL to match the redirect behavior
154+
canonical: absoluteHref(getPagePath(pages, page), true).replace(/\/+$/, ''),
154155
},
155156
openGraph: {
156157
images: [

0 commit comments

Comments
 (0)