Implement structured data (Schema.org)
Guide to implementing structured data (JSON-LD) in your Shoporama theme for better display in search results.
Structured data (Schema.org) helps Google and other search engines understand the content on your pages. For an online store, it is particularly relevant to implement product markup, store information and product reviews.
What is structured data?
Structured data is a standardized way of describing page content in a format that search engines understand. It can provide you with rich snippets in search results such as stars, prices and availability directly in Google.
Product markup (Product)
The most important type for an online store is Product markup. Here is an example in JSON-LD format that you can insert into your product template:
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Product", "name": "<{$product->getName()|escape:'javascript'}>", "image": "<{$product->getImages()[0]->getSrc(800,800,'fit')}>", "description": "<{$product->getDescription()|strip_tags|escape:'javascript'}>", "sku": "<{$product->getOwnId()|escape:'javascript'}>", "offers": { "@type":"Offer", "price":"<{$product->getPrice()}>", "priceCurrency": "<{$webshop->getCurrencyCode()}>", "availability": "<{if $product->getStock() > 0}>https://schema.org/InStock<{else}>https://schema.org/OutOfStock<{/if}>" } } </script>
Store information (LocalBusiness)
You can also add information about your business. It is recommended to place this in your footer or on your "about us" page:
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Store", "name": "<{$webshop->getName()|escape:'javascript'}>", "url": "https://<{$webshop->getDomain()}>", "telephone": "<{$webshop->getPhone()|escape:'javascript'}>", "email": "<{$webshop->getEmail()|escape:'javascript'}>" } </script>
Product reviews (AggregateRating)
If you use Shoporama's review system, you can add review markup. This can give stars in the search results:
"aggregateRating": { "@type":"AggregateRating", "ratingValue":"<{$product->getAverageRating()}>", "reviewCount":"<{$product->getReviewCount()}>" }
Test your structured data
Use Google tools to validate your markup:
- Rich Results Test - check if your markup provides rich snippets
- Schema Markup Validator - validate the syntax
Tip: JSON-LD
JSON-LD is the recommended format for structured data. It is placed in a <script> tag and does not affect the visual appearance of the page.
Need help with structured data? Contact us at support@shoporama.dk.