在您的 SEO 组件本身中创建两个对象
首先,
const schemaOrgWebPage = {
"@context": "http://schema.org",
"@type": "WebPage",
url: siteUrl,
headline: "Your Headline here",
inLanguage: "en",
mainEntityOfPage: siteUrl,
description: "your description here",
name: "your name here",
author: {
"@id": "author name",
},
copyrightHolder: {
"@id": "copyright holder name",
},
copyrightYear: "2020",
creator: {
"@id": "creator name",
},
publisher: {
"@id": "publisher name",
},
datePublished: "date of your publication",
image: {
"@type": "ImageObject",
url: "image url",
},
}
第二,
const orgaCreator = {
"@context": "http://schema.org",
"@id": `${siteUrl}`,
"@type": "WebPage",
address: {
"@type": "PostalAddress",
addressCountry: "put your country name",
addressLocality: "put your locality name",
},
name: "your name here",
alternateName: "your nick name",
description: description || defaultDescription,
url: siteUrl,
email: "your email address",
founder: "founder name",
foundingDate: "founding date",
foundingLocation: "founding location",
image: {
"@type": "ImageObject",
url: `${siteUrl}${image || defaultImage}`,
height: "512",
width: "512",
},
logo: {
"@type": "ImageObject",
url: `${siteUrl}${image || defaultImage}`,
height: "60",
width: "60",
},
sameAs: [
"https://www.facebook.com/put-your-user-id-here",
"https://stackoverflow.com/put-your-user-id-here",
"https://github.com/put-your-user-id-here",
"https://www.instagram.com/put-your-user-id-here",
"https://twitter.com/put-your-user-id-here",
"https://www.linkedin.com/put-your-user-id-here",
],
}
然后最后在 Helmet 标签中添加这个
<Helmet>
<html lang="en" />
....
....
<script type="application/ld+json">
{JSON.stringify(schemaOrgWebPage)}
</script>
<script type="application/ld+json">{JSON.stringify(orgaCreator)}
</script>
</Helmet>
如果您想测试结构化数据,请在部署网站后转到
https://search.google.com/structured-data/testing-tool/u/0/ 并将您的网站网址放在那里,它会让您深入了解您的结构化数据。