Skip to content

Commit 3925efe

Browse files
authored
feat(seo): add BlogPosting JSON-LD structured data to blog posts (#2018)
1 parent c667ef6 commit 3925efe

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

blog/src/theme/BlogPostPage/index.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,37 @@ const BlogPostPage = (props: Props): JSX.Element => {
133133
{tags.length > 0 && (
134134
<meta property="article:tag" content={tags.map((tag) => tag.label).join(',')} />
135135
)}
136+
<script type="application/ld+json">
137+
{JSON.stringify({
138+
'@context': 'https://schema.org',
139+
'@type': 'BlogPosting',
140+
headline: title,
141+
description,
142+
datePublished: date,
143+
...(image && { image }),
144+
author: authors.map((author) => ({
145+
'@type': 'Person',
146+
name: author.name,
147+
...(author.url && { url: author.url }),
148+
...(author.imageURL && { image: author.imageURL }),
149+
})),
150+
...(tags.length > 0 && {
151+
keywords: tags.map((tag) => tag.label).join(', '),
152+
}),
153+
publisher: {
154+
'@type': 'Organization',
155+
name: 'Apache APISIX',
156+
logo: {
157+
'@type': 'ImageObject',
158+
url: 'https://apisix.apache.org/img/logo2.svg',
159+
},
160+
},
161+
mainEntityOfPage: {
162+
'@type': 'WebPage',
163+
'@id': metadata.permalink,
164+
},
165+
})}
166+
</script>
136167
</Seo>
137168

138169
<BlogPostItem frontMatter={frontMatter} assets={assets} metadata={metadata} isBlogPostPage>

0 commit comments

Comments
 (0)