ECM-4Recommended
Describe each product for machines from the same data
Give every product page schema.org Product markup with one Offer per variant. Build its price, currency and availability from the same server data that renders the visible page.
How to do it
Search engines, price comparison sites and shopping agents read the markup. A price in the markup that differs from the page misleads them and the buyer, as Structured data that misleads explains. Include the SKU, the GTIN where one exists, the price, the currency and the availability from the stock count. Use ProductGroup with hasVariant when variants share a page. The general markup rules are in Describe each page for machines.
Examples
JavaScript example
export const productJsonLd = (product, stockOf) => ({
'@context': 'https://schema.org', '@type': 'ProductGroup', name: product.title, productGroupID: product.id,
hasVariant: product.variants.map(v => ({
'@type': 'Product', sku: v.sku, gtin: v.gtin, name: `${product.title} ${Object.values(v.options).join(' ')}`,
offers: { '@type': 'Offer', price: (v.prices.EUR / 100).toFixed(2), priceCurrency: 'EUR',
availability: stockOf(v.id) > 0 ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock' },
})),
});
Python example
def product_json_ld(product, stock_of) -> dict:
return {
"@context": "https://schema.org", "@type": "ProductGroup", "name": product.title, "productGroupID": product.id,
"hasVariant": [{
"@type": "Product", "sku": v.sku, "gtin": v.gtin,
"offers": {"@type": "Offer", "price": f"{v.prices_minor['EUR'] / 100:.2f}", "priceCurrency": "EUR",
"availability": "https://schema.org/InStock" if stock_of(v.id) > 0 else "https://schema.org/OutOfStock"},
} for v in product.variants],
}
How to check
A test renders every product page and compares each Offer price, currency and availability with the visible price and stock state. They match for every variant.
Sources
Related rules
- SEO-59 Structured data that misleads in SEO
- SEO-16 Describe each page for machines in SEO
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ecommerce/catalog-and-prices/product-markup">Agent Wranglers e-commerce and fulfilment playbook</a>. In code you write, add a comment next to it with the same link.