How to set structured data to dynamic pages?

That worked, @mnazwan Thanks!

So, how to setup in dynamic page JSON code… ? i’m lost :frowning:

Does anyone know if there is a way to add an additional schema markup (2)?

Reviving this topic

These are some easy steps to follow if the content is visible on the page. For this example, I have a list of Event Titles, stored in the page’s dataset that I want to use as dynamic variables in a webpage schema.

  1. On the dynamic page template, I connect the page field to my data


2. Update or take note of the on-page field id, in this case it’s #eventTitle

  1. In the Velo panel…
    Import the libraries you need for the schema
import wixSeo from 'wix-seo';
import wixLocation from 'wix-location'; 

then build some variables

let title = wixSeo.title;
let url = wixLocation.url;
let itemObj = $w("#dynamicDataset").getCurrentItem();
let eventName = itemObj.eventTitle;

Here, I have used itemObj to get data related to the current page.
Then I’ve said that I want the eventName variable to give me the information in the eventTitle field for the current page.

  1. Now I can use the variables in the schema.
$w.onReady(() => {
wixSeo.setStructuredData(
    [{
        '@context': 'https://schema.org/',
        '@type': 'WebPage',
        'url': url,
        'name': title,
        'description': 'Find out what happened at ' + eventName + '. Learn more.' }]
)
})
; 

Testing the live page it renders as:

All together it looks like this:

import wixSeo from 'wix-seo';
import wixLocation from 'wix-location'; 

let title = wixSeo.title;
let url = wixLocation.url;
let itemObj = $w("#dynamicDataset").getCurrentItem();
let eventName = itemObj.eventTitle;

$w.onReady(() => {
wixSeo.setStructuredData(
    [{
        '@context': 'https://schema.org/',
        '@type': 'WebPage',
        'url': url,
        'name': title,
        'description': 'Find out what happened at ' + eventName + '. Learn more.' }]
)
})
; 

LOVELY THANKS!

I have just 1 question, how to add an “image” field and dynamically connect a link to the element’s image there, as this is done with the “name”, “author’s name” and other fields?