admin管理员组文章数量:1353001
Is there a way to provide custom Metadata to users based on the keywords from the search engine?
In order to improve SEO on my website, I'm trying to set up custom Metadata for both languages supported on my website: English and Portuguese. More specifically, provide the Next.js 13 Metadata API with some logic to achieve it.
Here's the code so far from the layout.tsx
file:
...
const englishMetadata = {
title: {
default: "brand",
template: "%s | brand.xyz",
},
description:
"Some description",
openGraph: {
title: "brand",
description:
"Some description",
url: "brand.xyz",
siteName: "brand",
type: "website",
},
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-video-preview": -1,
"max-image-preview": "large",
"max-snippet": -1,
},
},
icons: {
shortcut: "/favicon.png",
},
keywords:
"events clothing, ...",
};
const portugueseMetadata = {
title: {
default: "Brand",
template: "%s | brand.xyz",
},
description:
"Alguma descrição",
openGraph: {
title: "brand",
description:
"Alguma descrição",
url: "brand.xyz",
siteName: "brand",
type: "website",
},
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-video-preview": -1,
"max-image-preview": "large",
"max-snippet": -1,
},
},
icons: {
shortcut: "/favicon.png",
},
keywords:
"eventos, vestuário, ...",
};
// export const metadata: Metadata = ? portugueseMetadata : englishMetadata;
export const metadata: Metadata = {};
Is there a way to provide custom Metadata to users based on the keywords from the search engine?
In order to improve SEO on my website, I'm trying to set up custom Metadata for both languages supported on my website: English and Portuguese. More specifically, provide the Next.js 13 Metadata API with some logic to achieve it.
Here's the code so far from the layout.tsx
file:
...
const englishMetadata = {
title: {
default: "brand",
template: "%s | brand.xyz",
},
description:
"Some description",
openGraph: {
title: "brand",
description:
"Some description",
url: "brand.xyz",
siteName: "brand",
type: "website",
},
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-video-preview": -1,
"max-image-preview": "large",
"max-snippet": -1,
},
},
icons: {
shortcut: "/favicon.png",
},
keywords:
"events clothing, ...",
};
const portugueseMetadata = {
title: {
default: "Brand",
template: "%s | brand.xyz",
},
description:
"Alguma descrição",
openGraph: {
title: "brand",
description:
"Alguma descrição",
url: "brand.xyz",
siteName: "brand",
type: "website",
},
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-video-preview": -1,
"max-image-preview": "large",
"max-snippet": -1,
},
},
icons: {
shortcut: "/favicon.png",
},
keywords:
"eventos, vestuário, ...",
};
// export const metadata: Metadata = ? portugueseMetadata : englishMetadata;
export const metadata: Metadata = {};
Share
Improve this question
edited Jul 16, 2023 at 8:56
Youssouf Oumar
46.6k16 gold badges103 silver badges105 bronze badges
asked Jul 15, 2023 at 0:11
BrazBraz
1533 silver badges11 bronze badges
0
2 Answers
Reset to default 4You could use the generateMetadata
function. In an internalization setup where the URL param for the lang is called lang
, it would be something like this:
// app/[lang]/page.js
本文标签:
javascriptCustom Metadata depending on the language in NextjsStack Overflow
版权声明:本文标题:javascript - Custom Metadata depending on the language in Next.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1743922204a2562298.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论