Skip to content

Commit d5a299e

Browse files
committed
Add json+ld schema.org microdata for Blog Posts
1 parent 9ebeda7 commit d5a299e

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

components/NotionPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export function NotionPage({
250250
description={socialDescription}
251251
image={socialImage}
252252
url={canonicalPageUrl}
253+
isBlogPost={isBlogPost}
253254
/>
254255

255256
{isLiteMode && <BodyClassName className='notion-lite' />}

components/PageHead.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ export function PageHead({
1010
description,
1111
pageId,
1212
image,
13-
url
13+
url,
14+
isBlogPost
1415
}: types.PageProps & {
1516
title?: string
1617
description?: string
1718
image?: string
1819
url?: string
20+
isBlogPost?: boolean
1921
}) {
2022
const rssFeedUrl = `${config.host}/feed`
2123

@@ -99,6 +101,41 @@ export function PageHead({
99101
<meta property='og:title' content={title} />
100102
<meta name='twitter:title' content={title} />
101103
<title>{title}</title>
104+
105+
{ /* Better SEO for the blog posts */ }
106+
{ isBlogPost && (
107+
// See more here: https://schema.org/BlogPosting
108+
<script type="application/ld+json">
109+
{JSON.stringify({
110+
"@context": "https://schema.org",
111+
"@type": "BlogPosting",
112+
"@id": `${url}#BlogPosting`,
113+
"mainEntityOfPage": url,
114+
url,
115+
"headline": title,
116+
"name": title,
117+
description,
118+
"author": {
119+
"@type": "Person",
120+
// TODO: Google Rich Search results recommends adding the url:
121+
// "url": "..."
122+
"name": config.author,
123+
},
124+
"image": socialImageUrl,
125+
// TODO: Figure out how to pull these from the Notion content
126+
//"datePublished": "2024-11-08",
127+
//"dateModified": "2024-11-08",
128+
//"wordCount": "488",
129+
//"keywords": [
130+
// "tags",
131+
// "should",
132+
// "be"
133+
// "here"
134+
//],
135+
//"articleBody": "..."
136+
})}
137+
</script>
138+
)}
102139
</Head>
103140
)
104141
}

0 commit comments

Comments
 (0)