feat: add hreflang tags and international sitemap for SEO

- Added hreflang alternates to root layout for all locales (sr, en, de, fr)
- Added hreflang alternates to [locale] layout for all locales
- Updated sitemap to include all locale variants for every page
- Google will now properly index all language versions
This commit is contained in:
Unchained
2026-03-24 11:22:22 +02:00
parent 52b2eac5b5
commit a4e7a07adb
3 changed files with 123 additions and 14 deletions

View File

@@ -1,11 +1,36 @@
import { Metadata } from "next";
import { NextIntlClientProvider } from "next-intl";
import { getMessages, setRequestLocale } from "next-intl/server";
import { routing } from "@/i18n/routing";
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://dev.manoonoils.com";
export function generateStaticParams() {
return routing.locales.map((locale) => ({ locale }));
}
export async function generateMetadata({
params,
}: {
params: Promise<{ locale: string }>;
}): Promise<Metadata> {
const { locale } = await params;
const localePrefix = locale === "sr" ? "" : `/${locale}`;
const languages: Record<string, string> = {};
for (const loc of routing.locales) {
const prefix = loc === "sr" ? "" : `/${loc}`;
languages[loc] = `${baseUrl}${prefix}`;
}
return {
alternates: {
canonical: `${baseUrl}${localePrefix}`,
languages,
},
};
}
export default async function LocaleLayout({
children,
params,
@@ -22,4 +47,4 @@ export default async function LocaleLayout({
{children}
</NextIntlClientProvider>
);
}
}