Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO improvements: Add json+ld schema.org microdata for Blog Posts #653

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export function NotionPage({
description={socialDescription}
image={socialImage}
url={canonicalPageUrl}
isBlogPost={isBlogPost}
/>

{isLiteMode && <BodyClassName className='notion-lite' />}
Expand Down
39 changes: 38 additions & 1 deletion components/PageHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export function PageHead({
description,
pageId,
image,
url
url,
isBlogPost
}: types.PageProps & {
title?: string
description?: string
image?: string
url?: string
isBlogPost?: boolean
}) {
const rssFeedUrl = `${config.host}/feed`

Expand Down Expand Up @@ -99,6 +101,41 @@ export function PageHead({
<meta property='og:title' content={title} />
<meta name='twitter:title' content={title} />
<title>{title}</title>

{ /* Better SEO for the blog posts */ }
{ isBlogPost && (
// See more here: https://schema.org/BlogPosting
<script type="application/ld+json">
{JSON.stringify({
"@context": "https://schema.org",
"@type": "BlogPosting",
"@id": `${url}#BlogPosting`,
"mainEntityOfPage": url,
url,
"headline": title,
"name": title,
description,
"author": {
"@type": "Person",
// TODO: Google Rich Search results recommends adding the url:
// "url": "..."
"name": config.author,
},
"image": socialImageUrl,
// TODO: Figure out how to pull these from the Notion content
//"datePublished": "2024-11-08",
//"dateModified": "2024-11-08",
//"wordCount": "488",
//"keywords": [
// "tags",
// "should",
// "be"
// "here"
//],
//"articleBody": "..."
})}
</script>
)}
</Head>
)
}