Enter the page path, title, description, and image. Copy a function with a locale canonical and uk/en alternates.
import type { Metadata } from 'next'
type Props = { params: Promise<{ locale: string }> }
const baseUrl = 'https://muntai.top'
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { locale } = await params
const canonicalUrl = `${baseUrl}/${locale}/tools/my-tool`
return {
title: 'My tool — Muntai Tools',
description: 'Short description for search and messengers.',
alternates: {
canonical: canonicalUrl,
languages: {
uk: `${baseUrl}/uk/tools/my-tool`,
en: `${baseUrl}/en/tools/my-tool`,
},
},
openGraph: {
title: 'My tool — Muntai Tools',
description: 'Short description for search and messengers.',
url: canonicalUrl,
siteName: 'Muntai Tools',
type: 'website',
locale: locale === 'uk' ? 'uk_UA' : 'en_US',
images: [
{
url: 'https://muntai.top/assets-main/images/logo/muntai-image.jpg',
alt: 'My tool — Muntai Tools',
},
],
},
twitter: {
card: 'summary_large_image',
title: 'My tool — Muntai Tools',
description: 'Short description for search and messengers.',
images: ['https://muntai.top/assets-main/images/logo/muntai-image.jpg'],
},
}
}