Structured data on Wix dynamic pages using variable-driven schema
Module 57: Wix Dynamic Pages: Advanced SEO for Data-Driven Sites | Lesson 619 of 688 | 38 min read
By Michael Andrews, Wix SEO Expert UK
Static JSON-LD schema on a dynamic page produces the same schema markup on every URL, regardless of the unique content of each record. This defeats the purpose of structured data. Variable-driven schema uses Wix CMS field values to populate schema properties dynamically, so each page has unique, accurate structured data that reflects its specific content.
Why Static Schema Fails on Dynamic Pages
If you add a JSON-LD block with a fixed product name and price to a dynamic product page template, every product page on your site will report the same product name and price to Google. This is not just inaccurate — it can cause rich result failures because Google detects the mismatch between the schema data and the visible page content. Dynamic pages require dynamic schema.
Using Wix Variables in Custom Code Schema Blocks
Implementing variable schema on Wix dynamic pages
- Open your dynamic page in the Wix Editor and navigate to the page settings.
- Enable Wix Velo (developer tools) by clicking Dev Mode in the top bar if it is not already active.
- Open the page code panel and write a $w.onReady function that retrieves the current dataset item using $w("#dynamicDataset").getCurrentItem().
- Build your JSON-LD schema object in JavaScript, replacing all fixed values with dynamic field references from the current item object.
- Use document.head.insertAdjacentHTML or a custom HTML element to inject the completed JSON-LD schema string into the page head.
- Publish the site and open a published dynamic page in your browser, then use View Source to confirm the schema block appears with the correct field values for that specific record.
- Open a second dynamic page URL and repeat the source check to confirm the schema values are unique per record (not identical across all pages).
- Paste each dynamic page URL into the Google Rich Results Test tool to validate the schema and confirm eligibility for rich results.
- Repeat the validation test across at least five different records to ensure no schema errors exist across the full range of collection data.
Example: Product Schema with Dynamic Field Values
// Wix Velo code in dynamic page to inject product schema
import wixLocation from 'wix-location';
import { currentItem } from 'wix-dataset';
$w.onReady(function () {
const item = $w('#dynamicDataset').getCurrentItem();
const schema = {
"@context": "https://schema.org",
"@type": "Product",
"name": item.title,
"description": item.description,
"offers": {
"@type": "Offer",
"price": item.price,
"priceCurrency": "GBP",
"availability": "https://schema.org/InStock"
}
};
// Inject via Velo or custom element
});
How to Add Variable Schema Markup to Wix Dynamic Pages
Adding variable-driven JSON-LD schema to Wix dynamic pages requires Velo code that reads CMS collection field values and injects them into unique schema markup per page.
How to implement and test variable schema markup on Wix dynamic pages using Velo
- Open your dynamic page in the Wix Editor and enable Velo developer mode by clicking Dev Mode in the top navigation bar.
- Click "Page Code" to open the Velo code panel for the dynamic page.
- Write a $w.onReady function and inside it call $w("#dynamicDataset").getCurrentItem() to retrieve the current collection record's field values.
- Build a JSON-LD schema object in JavaScript using the retrieved field values: set "name" to item.title, "description" to item.description, and any other relevant schema properties to their corresponding collection fields.
- Create an HTML string from the schema object wrapped in <script type="application/ld+json"> tags.
- Use document.head.insertAdjacentHTML("beforeend", schemaString) to inject the completed schema into the page head dynamically.
- Publish the site and open a live dynamic page URL in your browser, then use View Page Source to confirm the JSON-LD schema block appears with the correct field values for that specific record.
- Open a second, different dynamic page URL and repeat the source check — confirm the schema values are unique to that record, not repeated from the first page.
- Paste each tested dynamic page URL into the Google Rich Results Test tool to validate the schema structure and check for errors.
- Test at least five different records including edge cases: records with very short descriptions, records with special characters in fields, and records with missing optional fields.
- Navigate to Wix Dashboard > Settings > Custom Code and confirm the Velo code is not duplicating any site-wide schema that may already be injected via custom code.
This lesson on Structured data on Wix dynamic pages using variable-driven schema is part of Module 57: Wix Dynamic Pages: Advanced SEO for Data-Driven Sites in The Most Comprehensive Complete Wix SEO Course in the World (2026 Edition). Created by Michael Andrews, the UK's No.1 Wix SEO Expert with 14 years of hands-on experience, 750+ completed Wix SEO projects and 425+ verified five-star reviews.