Google Search Console检测application/ld+json出现‘Unnamed Item’问题求助
修复.NET Core中FAQPage结构化数据的“Unnamed Item”错误
问题背景
在.NET Core应用的.cshtml页面中嵌入了以下FAQPage结构化数据代码,已尝试通过@Html.Raw包裹代码、为相关节点添加name属性来解决Google Search Console URL Inspection工具检测到的“Unnamed Item”错误,但问题仍未解决,需要修复该问题以提升页面SEO表现:
@Html.Raw(@"<script type=""application/ld+json""> { ""@context"": ""https://schema.org"", ""@type"": ""FAQPage"", ""name"": ""Microsoft Access FAQs"", ""mainEntity"": [ { ""@type"": ""Question"", ""name"": ""Can you help with a corrupted Access database?"", ""acceptedAnswer"": { ""@type"": ""Answer"", ""name"": ""Answer 1"", ""text"": ""Yes. We specialize in repairing damaged Microsoft Access files and preventing future corruption with best practices and SQL Server migration."" } }, { ""@type"": ""Question"", ""name"": ""Do I need Microsoft Access installed?"", ""acceptedAnswer"": { ""@type"": ""Answer"", ""name"": ""Answer 2"", ""text"": ""No. You can use the free Runtime version of Access to deploy your solution without a full Access license."" } } ] } </script>")
修复方案
1. 移除Answer节点的冗余name属性
根据Schema.org官方规范,Answer类型不需要name字段,多余的非标准字段可能导致Google解析逻辑异常。保留核心必填的text字段即可:
"acceptedAnswer": { "@type": "Answer", "text": "Yes. We specialize in repairing damaged Microsoft Access files and preventing future corruption with best practices and SQL Server migration." }
2. 改用对象序列化输出,避免手动转义错误
手动拼接JSON字符串容易出现转义或语法错误,建议通过C#对象序列化生成合法JSON,再通过@Html.Raw输出:
@{ var faqModel = new { @context = "https://schema.org", @type = "FAQPage", name = "Microsoft Access FAQs", mainEntity = new[] { new { @type = "Question", name = "Can you help with a corrupted Access database?", acceptedAnswer = new { @type = "Answer", text = "Yes. We specialize in repairing damaged Microsoft Access files and preventing future corruption with best practices and SQL Server migration." } }, new { @type = "Question", name = "Do I need Microsoft Access installed?", acceptedAnswer = new { @type = "Answer", text = "No. You can use the free Runtime version of Access to deploy your solution without a full Access license." } } } }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(faqModel); } @Html.Raw($"<script type=\"application/ld+json\">{json}</script>")
3. 确保结构化数据与页面可见内容一致
Google要求结构化数据中的FAQ内容必须在页面可见区域真实展示,不能仅存在于JSON代码中。需确保页面上实际渲染了对应的问题和答案文本,否则可能被判定为无效结构化数据。
4. 验证JSON合法性并重新提交
修复后,使用Google结构化数据验证工具检查JSON语法是否完全合规,确认无语法错误后,在Google Search Console中重新提交目标URL,再次通过URL Inspection工具验证错误是否消除。
内容的提问来源于stack exchange,提问作者Dave Finn
相关产品推荐
相关产品推荐

