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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user