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

NextJS站点JSON-LD Schema已添加但Google富结果测试未检测到求助

问题排查与解决方案

1. 核心问题:JSON字符串双重序列化

你的代码里做了两次JSON.stringify,导致最终输出到页面的是字符串化的JSON字符串,而非Google能解析的JSON-LD结构,这是Rich Results Test检测不到的直接原因。

错误代码:

const schemaJSON = JSON.stringify(schemas);
// ...
<Script
    id="org-schema"
    type="application/ld+json"
    dangerouslySetInnerHTML={{
       __html: JSON.stringify(schemaJSON), // 多余的第二次序列化
    }}
/>

修复后代码:

const schemaJSON = JSON.stringify(schemas);
// ...
<Script
    id="org-schema"
    type="application/ld+json"
    dangerouslySetInnerHTML={{
       __html: schemaJSON, // 直接使用第一次序列化的结果
    }}
/>

或者更简洁的写法:

<Script
    id="org-schema"
    type="application/ld+json"
    dangerouslySetInnerHTML={{
       __html: JSON.stringify(schemas),
    }}
/>

2. 优化Next.js Script组件加载策略

Google爬虫可能在脚本加载完成前就抓取页面,建议给Script组件指定strategy="beforeInteractive",确保Schema在页面初始渲染时就存在:

import Script from 'next/script';

// ...

<Script
    id="org-schema"
    type="application/ld+json"
    strategy="beforeInteractive"
    dangerouslySetInnerHTML={{
       __html: JSON.stringify(schemas),
    }}
/>

3. 修正Schema结构细节

虽然Schema.org验证通过,但Google对字段格式有更严格要求:

  • 把"ContactPoint": { ... }改成"contactPoint": { ... }(Schema规范中属性名需小写开头)
  • 确认image和logo的URL可正常访问,logo建议尺寸不小于112x112像素

4. 验证修复结果

修复后按以下步骤确认:

  • 打开页面源代码,搜索application/ld+json,确认输出的是标准JSON结构,而非转义后的字符串
  • 重新用Google Rich Results Test检测,或通过Google Search Console的URL检查工具抓取页面,查看Schema是否被识别

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 06:22:22