英文:
How can I add custom meta tags using static metadata objects in next.js 13
问题
export const metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export const metadata = {
other: { pinterest: "nopin" },
};
EDIT (April 18th):
I'm not sure why it seemed to be working before, but adding the meta tag as suggested by Mathieu (and the documentation) doesn't seem to actually work.
英文:
So I know that to block Pinterest on my site I need to embed this in my site's header <meta name="pinterest" content="nopin" />
, but I'm not sure how to do that in Next 13 using the new exported metadata object format? Looked at the documentation for that object but couldn't figure it out.
export const metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
EDIT (April 18th):
I'm not sure why it seemed to be working before, but adding the meta tag as suggested by Mathieu (and the documentation) doesn't seem to actually work.
I have this in my root layout file and pinterest pinning option still appears on my site
export const metadata = {
other: { pinterest: "nopin" },
};
答案1
得分: 2
添加自定义元数据,您可以使用其他类别:
export const metadata = {
other: { pinterest: "nopin" },
};
下一个构建将生成以下元数据:
<meta name="pinterest" content="nopin"/>
更多信息请参阅:https://beta.nextjs.org/docs/api-reference/metadata#other
英文:
to add custom metadata, you can use other category:
export const metadata = {
other: { pinterest: "nopin" },
};
next build will generate this metadata:
<meta name="pinterest" content="nopin"/>
More information here: https://beta.nextjs.org/docs/api-reference/metadata#other
答案2
得分: -3
将您的代码片段放入您的layout.js或page.js文件中,如下所示:
export const metadata = {
...[您之前的元数据,如标题、描述等]
pinterest: "nopin"
};
英文:
it seems you just have to put your piece of code in your layout.js or page.js, like this :
export const metadata = {
...[Your previous meta data, like title, description,...]
pinterest: "nopin"
};
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论