fix: ensure canonical URLs match actual URLs with locale prefix

- Update [slug]/page.tsx to always include locale in canonical URL
- Update by-oil/page.tsx to use consistent locale prefix
- Update by-concern/page.tsx to use consistent locale prefix
- All canonical URLs now match actual URLs: /{locale}/solutions/{slug}
This commit is contained in:
Unchained
2026-04-09 10:50:54 +02:00
parent 04d8d773bf
commit 14d7a3e21a
4 changed files with 120 additions and 5 deletions

View File

@@ -35,8 +35,8 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
const metaTitle = getLocalizedString(page.metaTitle, validLocale);
const metaDescription = getLocalizedString(page.metaDescription, validLocale);
const keywords = getLocalizedKeywords(page.seoKeywords, validLocale);
const localePrefix = validLocale === DEFAULT_LOCALE ? "" : `/${validLocale}`;
const canonicalUrl = `${baseUrl}${localePrefix}/solutions/${page.localizedSlugs[validLocale as "sr" | "en" | "de" | "fr"]}`;
const localePrefix = `/${validLocale}`;
const canonicalUrl = `${baseUrl}${localePrefix}/solutions/${slug}`;
return {
title: metaTitle,
@@ -45,7 +45,7 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
alternates: {
canonical: canonicalUrl,
languages: {
"sr": `${baseUrl}/solutions/${page.localizedSlugs.sr}`,
"sr": `${baseUrl}/sr/solutions/${page.localizedSlugs.sr}`,
"en": `${baseUrl}/en/solutions/${page.localizedSlugs.en}`,
"de": `${baseUrl}/de/solutions/${page.localizedSlugs.de}`,
"fr": `${baseUrl}/fr/solutions/${page.localizedSlugs.fr}`,

View File

@@ -19,7 +19,7 @@ export async function generateMetadata({
const t = await getTranslations({ locale: validLocale, namespace: "Solutions.ByConcern" });
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
const localePrefix = validLocale === DEFAULT_LOCALE ? "/sr" : `/${validLocale}`;
const localePrefix = `/${validLocale}`;
const canonicalUrl = `${baseUrl}${localePrefix}/solutions/by-concern`;
return {

View File

@@ -19,7 +19,7 @@ export async function generateMetadata({
const t = await getTranslations({ locale: validLocale, namespace: "Solutions.ByOil" });
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
const localePrefix = validLocale === DEFAULT_LOCALE ? "/sr" : `/${validLocale}`;
const localePrefix = `/${validLocale}`;
const canonicalUrl = `${baseUrl}${localePrefix}/solutions/by-oil`;
return {