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

Next.js App Router中如何添加自定义meta property属性?

解决Next.js 13.4 App Router中生成带property属性的元标签问题

在Next.js 13.4的App Router架构下,要生成带有property属性的自定义元标签(如<meta property="product:brand" content="Facebook">),需借助generateMetadata返回对象中的meta数组来定义这类标签,常规字段配置无法生成property属性的标签。

修改后的代码示例如下:

import type { Metadata } from 'next';

export async function generateMetadata(): Promise<Metadata> {
  
  return {
    title: 'Modern Furniture Crafted with Elegance',
    description:
      'Experience the beauty and craftsmanship. Buy furniture for your home online.',
    viewport: 'width=device-width, initial-scale=1.0, user-scalable=yes',
    appleWebApp: { capable: true },
    openGraph: {
      title: 'Modern Furniture Crafted with Elegance',
      description:
        'Experience the beauty and craftsmanship. Buy furniture for your home online.',
    },
    // 添加带property属性的自定义元标签
    meta: [
      {
        property: 'product:brand',
        content: 'Facebook',
      },
    ],
  };
}

meta数组支持添加多条自定义元标签,每条通过property指定属性名、content设置对应内容,Next.js会自动生成符合要求的<meta>标签。

内容的提问来源于stack exchange,提问作者jhon arab

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 08:23:18