首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RDFa与schema.org博客模式

RDFa与schema.org博客模式
EN

Stack Overflow用户
提问于 2012-09-08 05:35:31
回答 1查看 806关注 0票数 4

我很难弄清楚我是否对RDFa和schema.org博客类型做了正确的事情。我的博客曾经有这样的帖子列表:

代码语言:javascript
复制
<h2><a href="essays/why-orm-divides-us.html">Why ORM Divides Us</a></h2>
<h2><a href="essays/heretic-calculus.html">A Heretical Calculus</a></h2>

在尝试使用RDFa信息(特别是博客BlogPosting类型)对其进行扩展时,我想出了以下内容:

代码语言:javascript
复制
<div vocab="http://schema.org/" typeof="Blog">
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a property="url" href="essays/why-orm-divides-us.html">
      <span property="name">Why ORM Divides Us</span>
    </a>
  </h2>
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a property="url" href="essays/heretic-calculus.html">
      <span property="name">A Heretical Calculus</span>
    </a>
  </h2>
  ...

据我所知,用谷歌富片段测试工具,这看起来是正确的分析,但我真的不能说。我还有两次尝试:

代码语言:javascript
复制
<div vocab="http://schema.org/" typeof="Blog">
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a href="essays/why-orm-divides-us.html" property="name">Why ORM Divides Us</a>
  </h2>
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a href="essays/heretic-calculus.html" property="name">A Heretical Calculus</a>
  </h2>
  ...

<div vocab="http://schema.org/" typeof="Blog" rel="blogPosting">
  <h2 typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a property="url" href="essays/why-orm-divides-us.html">
      <span property="name">Why ORM Divides Us</span>
    </a>
  </h2>
  <h2 typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a property="url" href="essays/heretic-calculus.html">
      <span property="name">A Heretical Calculus</span>
    </a>
  </h2>
  ...

所以我想要几条信息:

  1. 如何判断是否实现了与这些模式之一的一致性?
  2. 我的哪一种选择是正确的,为什么?
  3. 为什么当我在链接上时,我似乎需要直接指定资源?
  4. 为什么<a>标记在RDFa演示工具和Google测试工具中的解析方式如此不同?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-08 15:51:55

您的第一个片段是正确的,我建议您使用它。第二个是不正确的,因为property="name“将以href值为目标,所以不要使用该值。第三种方法也是正确的,它使用了RDFa的一个更高级的特性,称为链接(通过rel属性)。如果你愿意的话,使用它是完全有效的,谷歌也理解它。

  1. 我不知道有任何官方的schema.org验证器,但有时会告诉您是否有问题(但并不总是如此)。您还可以使用RDFa和http://validator.w3.org/nu/验证HTML + http://www.w3.org/2012/pyRdfa/Validator.html标记。
  2. 你的第一个和第三个是正确的,第二个是错误的(见上文)。我推荐第一个。
  3. 嗯,链接的url有两个用途,首先它用于标识web上的对象,还显式地用于schema.org所需的'url‘属性。虽然第二个属性是特定于schema.org的属性。
  4. 这是谷歌在RDFa语法本身之上添加的东西,纯RDFa解析器不会返回像这样分组的值和href。我想谷歌这样做是为了方便,但我同意这可能会让人感到困惑。
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12328312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档