Is there any way to write dynamic html code or implement schema.org in the dynamic pages?
I also want to know how it can be done for dynamic pages
hey i have find out a way to it. finally
How did you figure it out?
@domovservices How did you end up doing it to get it to work?
You can use the Wix SEO API to pull in dynamic variables and add in custom schema on dynamic pages. This is included in the site’s HTML via Server Side Rendering.
For instance, this is an example of BreadcrumbList schema (which can make your site eligible for Rich Results ) added to a dynamic page. In this case the “title” variable will update as each page is loaded.
BreadcrumbList schema:
import wixSeo from 'wix-seo';
let title = wixSeo.title;
$w.onReady(() => {
wixSeo.setStructuredData(
[{
'@context': 'https://schema.org/',
'@type': 'BreadcrumbList',
'itemListElement': [{
'@type': 'ListItem',
'position': 1,
'name': 'Home',
'item': 'https://www.exmaple.com/'
}, {
'@type': 'ListItem',
'position': 2,
'name': 'Experience',
'item': 'https://www.example.com/folder-name'
},{
'@type': 'ListItem',
'position': 3,
'name': title
}
]
}])
});
Simple WebPage Schema :
import wixSeo from 'wix-seo';
import wixLocation from 'wix-location';
let url = wixLocation.url;
let title = wixSeo.title;
let summary = $w("#page1").description;
$w.onReady(() => {
wixSeo.setStructuredData(
[{
'@context': 'https://schema.org/',
'@type': 'WebPage',
'url': url,
'name': title,
'description': summary
}])
});