Skip to content

Commit 2df01d8

Browse files
Mlaz-codepaperclip-resolver[bot]
andauthored
fix(seo): add trailing slash to homepage canonical/hreflang URLs (#235)
Semrush flagged 9 hreflang conflicts on locale homepages (/en/, /de/, /es/, /pt-BR/) because canonical and hreflang tags pointed to /en (no trailing slash) while the page is served at /en/ (with trailing slash). This caused "Conflicting hreflang and rel=canonical" and "No self-referencing hreflang" errors. Fix: append trailing slash to path and subPath when mdxPath is empty (homepage). Deep page URLs are unchanged. Co-authored-by: paperclip-resolver[bot] <3736210+paperclip-resolver[bot]@users.noreply.github.com>
1 parent c8b0c8f commit 2df01d8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/[lang]/[[...mdxPath]]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const DEFAULT_LOCALE = 'en'
1010
export async function generateMetadata(props) {
1111
const params = await props.params
1212
const { metadata } = await importPage(params.mdxPath, params.lang)
13-
const path = params.mdxPath ? `/${params.lang}/${params.mdxPath.join('/')}` : `/${params.lang}`
14-
const subPath = params.mdxPath ? `/${params.mdxPath.join('/')}` : ''
13+
const path = params.mdxPath ? `/${params.lang}/${params.mdxPath.join('/')}` : `/${params.lang}/`
14+
const subPath = params.mdxPath ? `/${params.mdxPath.join('/')}` : '/'
1515
const languages: Record<string, string> = {}
1616
for (const l of LOCALES) {
1717
languages[l] = `https://docs.sharpapi.io/${l}${subPath}`

0 commit comments

Comments
 (0)