标签: json-ld

在JSON-LD中,是否可以扩展上下文?

我有一个JSON-LD文档.

{
  "@id": "VDWW1LL3MZ",
  "first_name": "Vincent",
  "last_name": "Willems",
  "knows":["MartyP"],
  "@context": {
    "foaf": "http://xmlns.com/foaf/0.1/",
    "first_name": "foaf:givenName",
    "last_name": "foaf:familyName",
    "knows": "foaf:knows",
    "MartyP": { 
      "@id": "http://example.com/martyp",
      "first_name": "Marty",
      "last_name": "P"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

现在,本文档的部分上下文是在运行时(Marty P对象)生成的,但foaf前缀定义是静态的,并且对每个文档都重复.

如果我有10个前缀定义,将它们放在每个文档中会感到浪费.所以我想做点什么

generated document:

{
  "@id": "VDWW1LL3MZ",
  "first_name": "Vincent",
  "last_name": "Willems",
  "knows":["MartyP"],
  "@context": {
    "@extends": "http://example.com/base_context.jsonld",
    "MartyP": { 
      "@id": "http://example.com/martyp",
      "first_name": "Marty",
      "last_name": "P"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

base_context.jsonld:

  {
    "foaf": "http://xmlns.com/foaf/0.1/",
    "first_name": "foaf:givenName",
    "last_name": "foaf:familyName",
    "knows": "foaf:knows"
  }
Run Code Online (Sandbox Code Playgroud)

这可能吗?

semantic-web linked-data json-ld

4
推荐指数
1
解决办法
749
查看次数

在 JSON-LD 中创建一系列产品

有人可以发现我下面的代码有什么问题吗?(它不会在 Google 结构化测试工具中验证。)我正在尝试创建 JSON-LD 代码以添加到有多个待售产品的页面。

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@graph": [
{
  "@type": “Product”,
  "name": “tshirt",
  “description”: "test copy 1.”,
  “image”: “image.jpg”
},
{
  "@type": “Product”,
  "name": “tshirt 2",
  “description”: "test copy 2.”,
  “image”: “image2.jpg”
}
]
}
</script>
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢!

seo structured-data json-ld

4
推荐指数
1
解决办法
4160
查看次数

结构化数据> Microdata&Json-LD>实体ID>片段标识符

我想知道使用片段标识符格式引用实体是否更好/适当 - 基本上是通过在名称前插入哈希

[url] + # + [name] => http://example.com/page/#webPage

编辑:

根据来自慷慨和伟大的@Unor的回复,我添加了这个编辑以试图限制我的查询范围并澄清我遇到的主要问题.我还删除了大部分原始问题(大约95%)(事后看来)我觉得有缺点:1.我的核心问题; 2.对未来读者的好处.

这是我的问题:

在微数据的itemid和json-ld的@id值开始时手动键入哈希的做法是否有效?

以下是我更详细的问题:

我可以在微数据的itemid值和json-ld的@id值中插入HASH符号(#),以便通过正确有效地使用片段标识符来创建有效的结果URI吗?

所以,如果这是在网页上:

<div itemscope itemtype="http://www.schema.org/Person" itemid="#joe"></div>
Run Code Online (Sandbox Code Playgroud)

或者,如果这也在网页上:

{"@context":"http://schema.org",
"@type":"Person",
"@id":"#Joe"}
Run Code Online (Sandbox Code Playgroud)

我知道他们会被读到这样的uri(假设消费者的相对构造是谷歌的结构化数据测试工具):

http://www.example.com/page#joe
Run Code Online (Sandbox Code Playgroud)

那是uri:

  1. 有效的uri; 和

  2. 是否正确使用片段标识符(HASH)?

uri microdata data-structures json-ld iri

4
推荐指数
1
解决办法
1336
查看次数

schema.org 中相对 URL 的语义 JSON-LD 中的面包屑

schema.org网站给出了JSON-LD代表的面包屑的一个例子

<script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "BreadcrumbList",
 "itemListElement":
 [
  {
   "@type": "ListItem",
   "position": 1,
   "item":
   {
    "@id": "https://example.com/dresses",
    "name": "Dresses"
    }
  },
  {
   "@type": "ListItem",
  "position": 2,
  "item":
   {
     "@id": "https://example.com/dresses/real",
     "name": "Real Dresses"
   }
  }
 ]
}
</script>
Run Code Online (Sandbox Code Playgroud)

大部分内容对我来说都很清楚,但我对本示例中提供的链接的语义不是绝对确定。

我觉得令人困惑的是@id属性。它们的值是 URL,看起来这些应该指向由面包屑项目链接的实际网页。然而,属性的名称表明 URL 可能实际上指向某些本体中的概念标识符。是哪个?

无标记”选项卡包含一段未注释的 HTML,这表明我的第一个猜测是正确的,并且 URL 实际上指向网页。

<ol>
  <li>
    <a href="https://example.com/dresses">Dresses</a>
  </li>
  <li>
    <a href="https://example.com/dresses/real">Real Dresses</a>
  </li>
</ol>
Run Code Online (Sandbox Code Playgroud)

是这种情况吗,在这种情况下可以使用相对 URL 吗?

<script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "BreadcrumbList",
 "itemListElement":
 [
  {
   "@type": "ListItem", …
Run Code Online (Sandbox Code Playgroud)

schema.org json-ld

4
推荐指数
2
解决办法
3656
查看次数

Schema.org 中的指针究竟是什么以及如何将它们与 JSON-LD 一起使用?

schema.org 文档有时会提到“指针”。例如Product模式具有属性isSimilarTo

我明白,我可以直接使用 aProduct或 a Service。例如:

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": "BMW",
  "isSimilarTo": {
    "@type": "Product",
    "name": "Mercedes Benz"
  },
  "offers": {
    "@type": "Offer",
    "priceCurrency": "EUR",
    "price": "100000.00"
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

这是在这种情况下使用和解释术语“指针”的唯一且正确的方法吗?对于指针,我宁愿期望一些值(ID 或 URL 或类似的)只是指向另一个产品或服务。

schema.org json-ld

4
推荐指数
1
解决办法
701
查看次数

多语言网站的 Schema.org:正确填写公司和网站的内容

我在一个多语言网站上工作,我正在使用 JSON-LD 准备 Schema.org 标记。重要细节:本网站使用语言子目录。让我们考虑两种语言:

  • 英语: https://www.example.com/
  • 法语: https://www.example.com/fr/

我想把CorporationWebSite东西放在所有本地化的惠普上。一切正常,但对于@id,urlinLanguage属性:我不太知道我应该填写什么。

对于Corporation,我想我是对的:我将在所有页面上使用默认 url 并以此为基础@id

{
    "@context": "http://schema.org",
    "@type": "Corporation",
    "@id": "https://www.example.com/#organization",
    "name": "Example",
    "url": "https://www.example.com/",
...
Run Code Online (Sandbox Code Playgroud)

但是WebSite,在我的法国 HP 上,房地产的最佳举措是什么?从技术上讲,/fr/子文件夹是example.com/域的一部分。但是@idinLanguageurl没有告诉我的网站也适用于讲法语的人。

{
    "@context": "http://schema.org",
    "@type": "WebSite",
    "@id": "https://www.example.com/#website",   // should this be "https://www.example.com/fr/#website" ?
    "name": "Example",
    "url": "https://www.example.com/",   // should this be "https://www.example.com/fr/" ?
    "inLanguage": "en",   // …
Run Code Online (Sandbox Code Playgroud)

multilingual localization structured-data schema.org json-ld

4
推荐指数
1
解决办法
3441
查看次数

JSON-LD 和元标记

我正在处理我客户的网站并试图找出原因以及如何使用丰富的片段。让我感到困惑的是这些片段如何与元标记一起工作。

假设我有以下元标记和这个 JSON-LD 片段:

<title>Beachwalk Beachwear & Giftware</title>
<meta name="description" content="Cloths for sale." />
<h1>Cheap cloths for sale</h1>
Run Code Online (Sandbox Code Playgroud)
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "LocalBusiness",
  "address": {
    "@type": "PostalAddress",
    "addressLocality": "Mexico Beach",
    "addressRegion": "FL",
    "streetAddress": "3102 Highway 98"
  },
  "description": "A superb collection of fine gifts and clothing.",
  "name": "Beachwalk Beachwear & Giftware",
  "telephone": "850-648-4200"
}
</script>
Run Code Online (Sandbox Code Playgroud)

如果我已经在使用元标记,那么使用这些片段有什么意义?我是否应该在具有相同属性的每个页面上使用相同的片段?例如相同的开放时间、电子邮件和电话?

或者片段描述只是页面的简短摘要?和名字一样,应该和那个一样h1吗?

html meta-tags rich-snippets schema.org json-ld

4
推荐指数
1
解决办法
2736
查看次数

你如何结合几个JSON-LD标记?

我发现很难将几个或几个JSON-LD标记合并为一个新手.你能告诉我我做错了什么吗?

当我在Google结构化数据测试工具中输入以下标记时,它只显示Organization模式类型的结果,同时也有BreadcrumbList类型.

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"legalName": "Example INC",
"logo": "https://www.example.com/image.png",
"url": "https://www.example.com/",
"sameAs": [
"https://www.facebook.com/example",
"https://www.linkedin.com/company/example",
"https://twitter.com/example",
"https://www.youtube.com/user/example",
"https://en.wikipedia.org/wiki/example"
]
}
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": "1",
"item": {
"@id": "https://www.example.com/",
"name": "Homepage" 
}
}
]
</script>
Run Code Online (Sandbox Code Playgroud)

html json json-ld

4
推荐指数
1
解决办法
1910
查看次数

如何将 json-ld 添加到 Vue 3?

当尝试将 json-ld 脚本标签添加到传送到 HEAD 的部分时,Vue 3 编译器失败并显示以下错误:

VueCompilerError: Tags with side effect (<script> and <style>) are ignored in client component templates.

模板:

<template>
  <teleport to="head">
    <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "WebSite",
        "url": "https://www.example.com/",
        "potentialAction": {
          "@type": "SearchAction",
          "target": "https://query.example.com/search?q={search_term_string}",
          "query-input": "required name=search_term_string"
        }
      }
    </script>
  </teleport>
  <div>
    Hello world!
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)

如何在不安装额外依赖项的情况下添加此 json-ld 标签?

json-ld vue.js vuejs3

4
推荐指数
1
解决办法
3335
查看次数

Google结构化数据错误:"为http://www.example.com/提供的所有值必须具有相同的域名."

我想在Google搜索中添加公司联系人.我在Google的结构化数据测试工具中测试了以下代码,但它抛出了这个错误:

Google SDTT:1错误

https://coda-resume.herokuapp.com/(提供的所有值http://www.example.com/必须具有相同的域.)

这是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>
Run Code Online (Sandbox Code Playgroud)

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

google-search schema.org json-ld google-rich-snippets

3
推荐指数
1
解决办法
5782
查看次数