html - 当值为图像时使用 AggregateRating 和 ratingValue

标签 html microdata rich-snippets

我正在尝试向我的网站添加一些丰富网页摘要,但在 AggregateRating 部分遇到了一些困难,因为我的 ratingValue 的值仅显示为图像。

我的标记如下所示:

<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
    <th>Rating:</th>
    <td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <img itemprop="ratingValue" class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
    </td>
</tr>

据我所知,这是有效的 HTML,因为文本值可作为 ALT 文本使用,因此符合可访问性指南。但是,我不确定如何将此 ALT 标记为 ratingValue 的值。

有人知道我应该在这里做什么吗?

谢谢。


好的,在使用 Google Rich Snippets Tester 数小时后,我得出的结论是:

<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
    <th>Rating:</th>
    <td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <meta itemprop="ratingValue" content="4.5">
        <img class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
    </td>
</tr>

这似乎被正确地拾取了。

最佳答案

您的做法是正确的。只需在适当的位置添加一个标签并将值设置为“ratingValue”。它不会在页面呈现给用户时显示。

所以你会使用这个标签: <meta itemprop="ratingValue" content="4.5">

http://schema.org/Review范围内在您的文档中,就像您在更新中显示的那样。

关于html - 当值为图像时使用 AggregateRating 和 ratingValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6889256/

相关文章:

html - 奇怪的 HTML 注释行为

javascript - HTML - 单击时带有 html 部分的新页面

schema.org - Google SDTT错误: “The review has no reviewed item specified.”

javascript - React 中真正的自定义属性(例如微数据)

schema.org - 无法使用 PostalAddress 验证事件丰富代码段,但没有地点

seo - RDFa 面包屑在 Google SERP 中未按预期工作

javascript - 单击时上下滑动 Div

javascript - 如何引用div标签的Javascript函数来添加逗号?

blogs - Schema.org:博客项目类型适用性

google-search-console - 星级评分未显示在 Google 中