如何使用HTML微数据和schema.org引用博客文章?

joe*_*son 11 html citations microdata schema.org

我的目标是使用HTML微数据引用博客文章.

如何改进引用的以下标记?

我正在寻求语法和语义的改进,以产生与HTML5标准一致的结果,在当前浏览器中呈现良好,并在搜索引擎中进行良好的解析.

这个问题的赏金是专家建议和指导.我的研究提出了许多意见和片段,所以我正在寻找明确的答案,完整的样本和规范的文档.

这是我正在进行的工作,我正在寻求有关它正确性的建议:

  1. 使用<div class="citation">包装的一切.

  2. 使用<article>itemscopeBlogPost包裹邮寄信息,包括其嵌套的信息.

  3. 使用<header><h1 itemprop="headline">包装帖子名称链接.

  4. 使用<cite>包装后的名称.

  5. 使用<footer>包裹作者信息和博客信息.

  6. 使用<address>包裹笔者链接和名称.

  7. 使用rel="author"注释链接到作者的名字.

  8. 使用itemprop="isPartOf"到后连接到博客.

这是我正在进行的HTML源代码:

<!-- Hello World authored by Alice posted on Bob's blog -->
<div class="citation">
  <article itemscope itemtype="http://schema.org/BlogPosting">
    <header>
      <h1 itemprop="headline">
        <a itemprop="url" href="…">
          <cite itemprop="name">Hello World</cite>
        </a>
      </h1>
    </header>
    <footer>
      authored by
      <span itemprop="author" itemscope itemtype="http://schema.org/Person">
        <address>
          <a itemprop="url" rel="author" href="…">
            <span itemprop="name">Alice</span>
          </a>
        </address>
      </span>
      posted on
      <span itemprop="isPartOf" itemscope itemtype="http://schema.org/Blog">
        <a itemprop="url" href="…">
          <span itemprop="name">Bob's blog</span>
        </a>
      </span>
    </footer>
  </article>
</div>
Run Code Online (Sandbox Code Playgroud)

迄今为止的相关说明:

  • <cite>标签W3参考说,标签是"短语水平",因此它就像一个内嵌跨度,而不是块股利.但<article>标签似乎从使用中受益<h1>,<header>,<footer>.据我所知,该规范没有给出通过使用<cite>包装来引用文章的解决方案<article>.是否有解决方案或解决方法?(正在进行的工作通过使用来捏造这个<div class="citation">)

  • <address>标签W3参考称内容"的地址元素不能被用来表示任意地址,除非这些地址其实都是相关的联系信息." 据我所知,规范没有给出标记文章作者的URL和名称的解决方案,这与文章的联系信息不同.是否有解决方案或解决方法?(正在进行的工作通过使用<address>作者的URL和名称来捏造这一点)

请在评论中提问.随着我的了解,我会更新这篇文章.

uno*_*nor 10

如果您问我使用哪个标记作为博客帖子的链接列表(OP的上下文),而没有看到您的示例,我会选择以下内容:

<body itemscope itemtype="http://schema.org/WebPage">

<ul>
  <li>
    <cite itemprop="citation" itemscope itemtype="http://schema.org/BlogPosting">
      <a href="…" itemprop="url" rel="external"><span itemprop="name headline">Hello World</span></a>, 
      authored by <span itemprop="author" itemscope itemtype="http://schema.org/Person"><a href="…" itemprop="url" rel="external"><span itemprop="name">Alice</span></a></span>,
      posted on <span itemprop="isPartOf" itemscope itemtype="http://schema.org/CreativeWork"><a href="…" itemprop="url" rel="external"><span itemprop="name">Bob’s blog</span></a></span>.
    </cite>
  </li>
  <li>
    <cite itemprop="citation" itemscope itemtype="http://schema.org/BlogPosting">…</cite>
  </li>
</ul>

</body>
Run Code Online (Sandbox Code Playgroud)

使用分段内容元素article(如在您的示例中)肯定是可能的,尽管可能不常见(如果我理解您的用例正确):作为article分区内容元素,它在文档大纲中创建一个条目,可能是也可能不是你想要什么样的情况.(例如,您可以使用HTML5大纲查看大纲.)

分段内容元素可能不是最佳选择的另一个指示:您article不包含任何实际的"主要"内容.简单地说,一个切片内容元素的主要内容可以通过汽提其元数据来确定:header,footer,和address元件.(这不是明确指定的,但它来自章节中的定义.)

但是,没有这个内容没有.你可以很容易想象(也许你打算这样做),你会引用博客文章中的一个片段(使这个案例类似于搜索结果条目),在这种情况下你会有:

<article>
  <header></header>
  <blockquote></blockquote> <!-- the non-metadata part of the article -->
  <footer></footer>
</article> 
Run Code Online (Sandbox Code Playgroud)

我将进一步假设你想要使用article.

关于HTML5的说明:

  • 从语义上讲,div不需要包装.您可以直接添加citation该类article.

  • 如果header元素只包含一个heading元素,那么元素可选的(当你的标题不仅仅包含一个标题元素时,这个元素才有意义).但是,当然,拥有它并没有错.

  • 我更喜欢在a元素中包含cite元素(类似于规范中的第五个例子).

  • span元素只能包含段落式内容,所以address是不允许作为一个孩子.

  • 只有在包含联系信息的情​​况下才能使用该address元素.因此,如果此元素合适,则取决于链接页面上的可用内容:如果是联系表单,则为; 如果它是一个创作的博客帖子列表,没有.

  • author链接类型可能不适合,因为它的定义,以提供有关的作者信息article元素.但是,严格来说,是作者.如果article仅包含博客文章作者的实际内容,则使用author链接类型是合适的; 但在你的情况下,你正在写内容("由"撰写,"张贴在").

  • 您可能希望对所有外部链接使用external链接类型.

关于你的微数据的说明:

举个例子,这会给出:

<body itemscope itemtype="http://schema.org/WebPage">

<article itemprop="citation" itemscope itemtype="http://schema.org/BlogPosting" class="citation">
    <header>
      <h1>
          <cite itemprop="headline name"><a itemprop="url" href="…" rel="external">Hello World</a></cite>
      </h1>
    </header>
    <footer>
      authored by
      <span itemprop="author" itemscope itemtype="http://schema.org/Person">
          <a itemprop="url" href="…" rel="external"><span itemprop="name">Alice</span></a>
      </span>
      posted on
      <span itemprop="isPartOf" itemscope itemtype="http://schema.org/Blog">
        <a itemprop="url" href="…" rel="external"><span itemprop="name">Bob’s blog</span></a>
      </span>
    </footer>
</article>

</body>
Run Code Online (Sandbox Code Playgroud)

(考虑到所有事情,我仍然更喜欢无节的变体.)