Question:
How to add structural markup on dynamic page in studio
Product:
Wix Studio
What are you trying to achieve:
To add schema
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]
Hi , @Manjot_Singh
If you want to add structured markup (schema) on a dynamic page in Wix Studio, the best approach is usually to use the built-in SEO settings.
On a dynamic page, you can go to Page Settings - SEO - Advanced SEO - Structured Data and connect your schema fields to your CMS collection .This ensures each page outputs unique and accurate structured data for search engines.
import * as wixSeo from ‘@wix/site-seo’;
import * as wixLocation from ‘@wix/site-location’;
$w.onReady(() => {
$w("#dynamicDataset").onReady(async () => {
const item = $w("#dynamicDataset").getCurrentItem();
const url = await wixLocation.location.url();
wixSeo.seo.setStructuredData(\[{
'@context': 'https://schema.org',
'@type': 'JobPosting',
title: item.jobTitle,
url,
datePosted: item.datePosted,
validThrough: item.validThrough,
description: item.jobDescription,
hiringOrganization: { name: item.companyName, logo: item.companyLogo },
jobLocation: { address: { addressLocality: item.city, addressRegion: item.region, addressCountry: item.country } },
employmentType: 'FULL_TIME',
baseSalary: { currency: 'USD', value: { value: item.salary, unitText: 'YEAR' } }
}\]);
console.log(\` Job schema added for ${item.jobTitle}\`);
});
});
If you want to add structured data to your Wix site without writing custom code, you can use this app: JSON-LD Schema . It allows you to manage schema markup, including on dynamic pages. Using the app is optional
Disclaimer - I’m connected to this app .
Hope this helps !