css - 使用 CSS 隐藏 'aggregateRating'

标签 css schema.org microdata google-rich-snippets

我正在为客户开发网站。他们用微数据标记了他们在网站上显示的个人评论,但没有包括相应的 aggregateRating 属性。

我已经通知他们,他们需要包含 aggregateRating 属性,以便让 Google 在他们的有机列表中显示星星。客户回应说这没问题,但我必须向交互的用户隐藏与 aggregateRating - (ratingValue, ratingCount) 关联的任何值与他们的网站。

我知道 Google 不赞成这种做法,但我想知道是否有人成功地使用 CSS 隐藏了评论 Schema.org?我所说的成功是指谷歌仍然在有机列表中显示星星。

最佳答案

无需使用 CSS 隐藏您的架构。并非所有模式数据都必须显示在网页上。考虑 JSON-LD 模式,它都在 head 中,所以这些值都不会显示。

HTML 架构允许您标记网页上不可见的内容。

From Schema.org :

Sometimes, a web page has information that would be valuable to mark up, but the information can't be marked up because of the way it appears on the page […]

[…]

<meta itemprop="ratingValue" content="4" />

完整代码片段:

<div itemscope itemtype="http://schema.org/Offer">
  <span itemprop="name">Blend-O-Matic</span>
  <span itemprop="price">$19.95</span>
  <div itemprop="reviews" itemscope    itemtype="http://schema.org/AggregateRating">
    <img src="four-stars.jpg" />
    <meta itemprop="ratingValue" content="4" />
    <meta itemprop="bestRating" content="5" />
     Based on <span itemprop="ratingCount">25</span> user ratings
  </div>
</div>

关于css - 使用 CSS 隐藏 'aggregateRating',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40538478/

相关文章:

javascript - 代码不在函数内部运行

css - 为什么 bootstrap-sass 不能与 Rails 一起工作?

javascript - jQuery :not with anchor exclude div and img elements

html - Schema.org 电话​​链接是否需要包装跨度元素?

schema.org - Schema.org、Goodrelations-vocabulary.org 和 Productontology.org 之间有什么关系?

jquery - 在窗口调整大小时禁用 CSS 转换?

seo - 我可以多次使用 alternateName 吗?

html - 使用没有 itemtype 的 itemprop

html - 为问答 HTML 设置微数据的正确方法

html - 您是否将 Schema Microdata 元标记放在 html 正文中?