Google structured data error: "All values provided for http://www.example.com/ must have the same domain."

Google structured data error: "All values provided for http://www.example.com/ must have the same domain."

我想添加 Corporate Contacts in Google Search. I test the following code in Google's Structured Data Testing Tool,但它抛出了这个错误:

https://coda-resume.herokuapp.com/ (All values provided for http://www.example.com/ must have the same domain.)

这里是 JSON-LD:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "https://coda-resume.herokuapp.com/",
  "logo": "http://www.example.com/logo.png",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+1-401-555-1212",
    "contactType": "customer service"
  }]
}
</script>

(我把它放在 head 元素中。)

这可能是 Google 的结构化数据测试工具中的错误。

(删除 contactPoint 属性 时,该工具不再报告错误,尽管代码段仍包含相同的 url 值。)

参见DieterDP’s answer in a related question

忽略开发级别的错误, 在现场制作中效果很好, 可能是因为,Google 的结构化数据测试工具考虑了 Live Domain

我刚刚意识到错误来自 @context 属性。

尝试将“http://schema.org”更改为您站点的 URL,Google 不再显示该错误,是的!错了! Google 工具中错误的特征是什么!

我认为这是一个错误并试图找到解决方案,但这不是一个错误至少我们不能从 Google 这种小错误方面考虑。基本上错误是说(为 https://search.google.com/structured-data/testing-tool/ must have the same domain.) so it's mean Google Tester aspecting URL value is "https://search.google.com/structured-data/testing-tool/ 提供的所有值”因此,如果您使用您的信息尝试此代码,只需保持原样保持 URL 值,您会发现它正常工作并且出现 0 个错误。

 <script type='application/ld+json'> {"@context": "http://www.schema.org","@type": "Organization","name": "Your Company Name","url": "https://search.google.com/structured-data/testing-tool/","logo": "https://cdn.com/cms/assets/companylogo.svg","contactPoint": {"@type": "ContactPoint","telephone": "+90 00 000 00","contactType": "Customer Service"}}</script>

我收到这个错误:

<script type="application/ld+json">
{{
  "@context": "http://schema.org",
  "@type": "Organization",
  "Url": "http://www.your-company-site.com",
  "Logo": "http://www.example.com/logo.png",
  "ContactPoint": [{
    "@type": "ContactPoint",
    "Telephone": "+ 1-401-555-1212",
    "ContactType": "customer service"
  }]
}
</script>

如果您使用 https://www.thegioididong.com 例如:

<script type="application/ld+json">
{{
  "@context": "http://schema.org",
  "@type": "Organization",
  "Url": "https://www.thegioididong.com/",
  "Logo": "https://www.thegioididong.com/logo.png",
  "ContactPoint": [{
    "@type": "ContactPoint",
    "Telephone": "+ 1-401-555-1212",
    "ContactType": "customer service"
  }]
}
</script>

您将在测试工具中遇到以下错误:

https://www.thegioididong.com/ (All values ​​provided for https://search.google.com/structured-data/testing-tool/ must have the same domain.)

发生这种情况是因为您在检查之前代码不在网络上。

将代码上传到网站,然后在 testing tool 中返回查看。现在您不会再收到任何错误。