LiquidBoost
← Back to library
Social proof Free

Star rating with SEO markup

Renders review stars from a rating metafield and adds matching schema.org markup for rich search snippets.

{%- assign rating = product.metafields.reviews.rating.value -%}
{%- assign count = product.metafields.reviews.rating_count -%}
{%- if rating and count and count > 0 -%}
  {%- assign full = rating.value | floor -%}
  <div class="star-rating" aria-label="Rated {{ rating.value }} out of {{ rating.scale_max }}">
    <span class="star-rating__stars" aria-hidden="true">
      {%- for i in (1..5) -%}{%- if i <= full -%}★{%- else -%}☆{%- endif -%}{%- endfor -%}
    </span>
    <span class="star-rating__count">{{ rating.value }} ({{ count }})</span>
  </div>
  <script type="application/ld+json">
  {
    "@context": "https://schema.org/",
    "@type": "Product",
    "name": {{ product.title | json }},
    "aggregateRating": {
      "@type": "AggregateRating",
      "ratingValue": {{ rating.value | json }},
      "reviewCount": {{ count | json }},
      "bestRating": {{ rating.scale_max | json }}
    }
  }
  </script>
{%- endif -%}
<style>
  .star-rating{display:inline-flex;align-items:center;gap:8px;font-size:14px}
  .star-rating__stars{color:#f5a623;letter-spacing:2px}
  .star-rating__count{color:#666}
</style>

Shows social proof at a glance and can earn star-rating rich snippets in Google results. Paste under the product title in main-product.liquid.

Notes

  • Uses Shopify’s standard reviews.rating and reviews.rating_count metafields, written by the free Shopify Product Reviews-style apps and many review apps.
  • The whole block is skipped when there are zero reviews, so you never publish an empty or “0 stars” state.
  • Only claim ratings you actually collected — fabricated aggregateRating markup violates Google’s guidelines and risks a manual penalty.