【问题标题】:Google's RDFa breadcrumbs for home and current page?谷歌主页和当前页面的RDFa面包屑?
【发布时间】:2018-06-09 09:17:39
【问题描述】:

因为我在任何地方都找不到合适的 RDFa 示例,所以我想在这里问一个问题。在Google's page 上有面包屑的示例,使用微数据或 RDFa 标记。当您单击“示例 2”旁边的“RDFa”下的“查看标记”时,您会看到这种特定类型面包屑的标记示例(据我所知,面包屑中的图像是可选的,所以我摆脱了他们):

<ol vocab="http://schema.org/" typeof="BreadcrumbList">
  <li property="itemListElement" typeof="ListItem">
    <a property="item" typeof="WebPage" href="https://example.com/books">
      <span property="name">Books</span>
    </a>
    <meta property="position" content="1">
  </li>
  ›
  <li property="itemListElement" typeof="ListItem">
    <a property="item" typeof="WebPage" href="https://example.com/books/sciencefiction">
      <span property="name">Science Fiction</span>
    </a>
    <meta property="position" content="2">
  </li>
  ›
  <li property="itemListElement" typeof="ListItem">
    <a property="item" typeof="WebPage" href="https://example.com/books/sciencefiction/awardwinnders">
      <span property="name">Award Winners</span>
    </a>
    <meta property="position" content="3">
  </li>
</ol>

不幸的是,它没有说明主页和当前页面的面包屑,所以我不知道如何构建它。

更准确地说,我的问题是什么propertytypeof 属性用于主页和当前页面?我是否应该只使用上面示例中的第一个链接作为主页而不更改标记中的任何内容,而当前页面只省略链接,因为它并不是真正需要的,所以它看起来像这样?:

<li property="itemListElement" typeof="ListItem">
  <a property="item" typeof="WebPage" href="https://example.com">
    <span property="name">Home Page</span>
  </a>
  <meta property="position" content="1">
</li>

   // Above is for Home, below is for Current. I omitted items 2 and 3 which are positioned somwhere in between..

<li property="itemListElement" typeof="ListItem">
  <span property="name">Current Page</span>
  <meta property="position" content="4">
</li>

【问题讨论】:

  • 为什么要对首页和当前页进行特殊处理?为什么不像“书籍”、“科幻小说”等一样添加它们?
  • @unor 至于当前页面我真的不需要它的链接,这就是为什么我没有用链接包装它,但是可以这样做吗?我不确定主页;在上面的示例中,我将其完全视为“书籍”、“科幻小说”等,但这是一条正确的路吗?

标签: html schema.org breadcrumbs google-rich-snippets rdfa


【解决方案1】:

没有理由对主页条目进行不同的处理,所以是的,就像其他条目一样提供它。

如果您想在不显示链接的情况下为当前页面提供条目,您仍可能需要指定WebPage 类型。这还允许您提供当前页面的 URL,而无需向页面添加用户可见的链接。

<li property="itemListElement" typeof="ListItem">
  <span property="item" typeof="WebPage" resource="/current-page.html">
    <span property="name">Current Page</span>
  </span>
  <meta property="position" content="4">
</li>

它使用span 元素代替a 元素。
resource 属性(来自 RDFa)指定项目的 URI(不创建超链接)。

【讨论】:

  • 一切对我来说似乎都是完全有效的。谢谢你的努力!最好的问候!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-01
  • 1970-01-01
相关资源
最近更新 更多