You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Next.js 13中使用Open Graph元标签?

在Next.js 13中配置Open Graph元数据的正确方式

你之前的写法有误,Open Graph相关属性不能直接作为metadata的顶层字段,需要嵌套在openGraph子对象里。

正确的配置示例如下:

export const metadata = {
  title: "this is the title of the web",
  description: "this is the description section",
  openGraph: {
    title: "this is open graph title for testing",
    description: "this is open graph description for testing",
    url: "https://你的站点域名.com",
    siteName: "你的站点名称",
    images: [
      {
        url: "https://你的站点域名.com/og-image.jpg",
        width: 1200,
        height: 630,
        alt: "站点OG图片描述",
      },
    ],
    type: "website",
  },
};
  • 所有Open Graph相关元数据都要放在openGraph对象内,属性名用驼峰格式(比如title对应HTML中的og:title标签)
  • 除了title和description,还可按需配置url、siteName、图片信息、页面类型等常用OG属性
  • 不同路由需要单独配置OG数据时,直接在对应页面组件中导出专属的metadata对象即可

内容的提问来源于stack exchange,提问作者Mohammed Bekele

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 13:12:02