Skip to content

Commit 4b96afb

Browse files
committed
feat(seo): add canonical URLs to page metadata
1 parent 3534f6b commit 4b96afb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lib/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const siteConfig = {
5252
staticRoutes: flattenByChildren(mainNav)
5353
.filter((item) => isInternalHref(item.href))
5454
.map((item) => (item.href === "/" ? "" : item.href)),
55+
siteUrl: process.env.SITE_URL?.replace(/\/$/, ""),
5556
};
5657

5758
export function getNavLabel(path: string): string | undefined {
@@ -72,6 +73,9 @@ export function buildPageMetadata(
7273
return {
7374
title: label,
7475
description,
76+
alternates: {
77+
canonical: path === "/" ? "/" : path.replace(/\/$/, ""),
78+
},
7579
openGraph: {
7680
title: label,
7781
description,

0 commit comments

Comments
 (0)