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

页面JSON-LD部署:多script元素还是单个嵌套结构?

这个问题其实挺常见的——尤其是在像阿迪达斯这类电商网站做结构化数据的时候,两种方案都是完全可行的,具体选哪种得看你的开发流程和维护需求,我给你拆解下:

一、保持多个独立script标签的情况

这种方式是很多网站默认的做法,优势很明显:

  • 维护更省心:不同类型的JSON-LD(比如Organization放在头部、BreadcrumbList跟着面包屑组件)可以由各自的代码模块生成,耦合度低,哪部分出问题直接找对应的模块就行,不用动其他内容。
  • 搜索引擎完全支持:谷歌、必应这些主流搜索引擎都能正确识别页面中多个独立的application/ld+json类型script标签,不会因为拆分就忽略某部分数据。

举个简单的拆分示例:

<!-- 头部的Organization -->
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "阿迪达斯",
  "url": "https://www.adidas.com.cn/",
  "logo": "https://example.com/adidas-logo.png"
}
</script>

<!-- 面包屑区域的BreadcrumbList -->
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {"@type":"ListItem","position":1,"name":"首页","item":"https://www.adidas.com.cn/"},
    {"@type":"ListItem","position":2,"name":"男子","item":"https://www.adidas.com.cn/men"},
    {"@type":"ListItem","position":3,"name":"运动鞋","item":"https://www.adidas.com.cn/men/shoes"}
  ]
}
</script>

二、合并到单个script标签的方法(完全可行)

如果你想把所有JSON-LD整合到一个script里,官方推荐用@graph属性来组织多个实体,这是Schema.org规范里专门用来表示多个结构化数据实体集合的方式。当然也可以用顶层数组,但@graph的可读性和规范性更强。

方法1:用@graph组织(推荐)

把所有不同类型的实体放到@graph数组里,只需要在顶层声明一次@context即可:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "name": "阿迪达斯",
      "url": "https://www.adidas.com.cn/",
      "logo": "https://example.com/adidas-logo.png"
    },
    {
      "@type": "WebSite",
      "name": "阿迪达斯中国官网",
      "url": "https://www.adidas.com.cn/",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://www.adidas.com.cn/search?q={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    },
    {
      "@type": "Store",
      "name": "阿迪达斯上海旗舰店",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "南京东路123号",
        "addressLocality": "上海",
        "postalCode": "200001"
      }
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {"@type":"ListItem","position":1,"name":"首页","item":"https://www.adidas.com.cn/"},
        {"@type":"ListItem","position":2,"name":"男子","item":"https://www.adidas.com.cn/men"},
        {"@type":"ListItem","position":3,"name":"运动鞋","item":"https://www.adidas.com.cn/men/shoes"}
      ]
    }
  ]
}
</script>

方法2:顶层数组(可行但不推荐)

直接用JSON数组包裹多个实体,每个实体需要单独声明@context:

<script type="application/ld+json">
[
  {
    "@context": "https://schema.org",
    "@type": "Organization",
    "name": "阿迪达斯"
  },
  {
    "@context": "https://schema.org",
    "@type": "WebSite",
    "name": "阿迪达斯中国官网"
  }
]
</script>

合并的优势:减少页面中script标签的数量,让HTML结构更简洁;如果所有结构化数据是由同一套后端逻辑统一生成,合并后管理起来也更方便。

⚠️ 注意:合并时一定要保证整个JSON的语法完全正确,哪怕一个逗号错了,整个script里的所有JSON-LD都可能无法被搜索引擎识别。

三、怎么选?

给你两个简单的判断标准:

  • 如果你的网站是模块化开发(比如面包屑组件自己生成BreadcrumbList、头部组件生成Organization),那保持拆分状态更合适,每个组件职责清晰,修改互不影响。
  • 如果所有JSON-LD是统一生成(比如后端一次性输出所有结构化数据),或者你追求页面的简洁性,那合并成单个带@graph的script标签是更好的选择。

不管选哪种,只要JSON语法正确,搜索引擎都能正常解析,核心还是看你的开发维护效率和页面架构需求。

内容的提问来源于stack exchange,提问作者Héctor León

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:17:14