fix: canonical URLs to always include locale prefix

Fixed Canonical Redirect Error in Google Search Console by ensuring
canonical URLs always include the locale prefix (/sr, /en, /de, /fr)
instead of omitting it for the default locale.

Changes:
- layout.tsx: Fixed canonical and hreflang URL generation
- page.tsx: Fixed homepage canonical URL
- contact/page.tsx: Fixed contact page canonical URL
- about/page.tsx: Fixed about page canonical URL
- products/page.tsx: Fixed products page canonical URL
- products/[slug]/page.tsx: Fixed product detail canonical URL

Before: /contact (when locale=sr)
After: /sr/contact (all locales)

Fixes: Canonical Redirect Error in Google Search Console
This commit is contained in:
Unchained
2026-04-06 15:32:24 +02:00
parent 2097280f20
commit 57bae7ed6f
6 changed files with 8 additions and 8 deletions

View File

@@ -19,7 +19,7 @@ export async function generateMetadata({ params }: AboutPageProps): Promise<Meta
const metadata = getPageMetadata(validLocale as Locale);
const keywords = getPageKeywords(validLocale as Locale, 'about');
const localePrefix = validLocale === DEFAULT_LOCALE ? "" : `/${validLocale}`;
const localePrefix = `/${validLocale}`;
const canonicalUrl = `${baseUrl}${localePrefix}/about`;
return {