Skip to content

Commit c0eac9a

Browse files
committed
fix: add fallback for breadcrumb name to fix SEO validation error
Google Search Console reported "Either name or item.name should be specified" for the last breadcrumb item. This occurred because post.title can be undefined, and JSON.stringify omits undefined values. Added fallback chain (post.title || post.sharedPost?.title || 'Post') and removed item property from last breadcrumb per Google's recommendation.
1 parent d5285ee commit c0eac9a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

packages/webapp/components/PostSEOSchema.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ export const getBreadcrumbJsonLd = (post: Post): string => {
149149
{
150150
'@type': 'ListItem',
151151
position: 3,
152-
name: post.title,
153-
item: post.commentsPermalink,
152+
name: post.title || post.sharedPost?.title || 'Post',
154153
},
155154
],
156155
});

0 commit comments

Comments
 (0)