Enhance SEO structured data in BaseLayout#407
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
et3 | c6802b1 | Commit Preview URL Branch Preview URL |
Jan 15 2026, 10:56 PM |
Summary of ChangesHello @zz-plant, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the site's SEO by implementing explicit 'WebPage' structured data for every rendered page, providing search engines with richer context about the content. Additionally, it refines the presentation of breadcrumb labels within the structured data, making them more user-friendly and improving overall data quality. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves SEO by adding WebPage structured data and making breadcrumb labels more readable. The changes are well-aligned with the goal. However, I've found a critical issue that was present before this PR but is highly relevant to these changes. The structuredData is stringified before the BreadcrumbList is added. This means the breadcrumb structured data is never actually included in the page's HTML. Given that this PR touches SEO and breadcrumbs, it's the perfect opportunity to fix this. To fix this, const structuredDataJson = JSON.stringify(structuredData); (currently on line 78) should be moved to after the if (pathSegments.length > 0) { ... } block (after line 107). I've also added a couple of suggestions to further improve the structured data quality.
| { | ||
| '@context': 'https://schema.org', | ||
| '@type': 'WebPage', | ||
| name: title, | ||
| description, | ||
| url: canonical, | ||
| inLanguage: 'en', | ||
| isPartOf: { | ||
| '@type': 'WebSite', | ||
| name: siteName, | ||
| url: siteBase, | ||
| }, | ||
| primaryImageOfPage: { | ||
| '@type': 'ImageObject', | ||
| url: seoImage.src, | ||
| width: seoImage.width, | ||
| height: seoImage.height, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
For better structured data and to follow JSON-LD best practices, it's recommended to add a unique @id for the WebPage entity. The canonical URL is the perfect candidate for this. This helps search engines uniquely identify and disambiguate this page from others, improving how your content is indexed and linked.
{
'@context': 'https://schema.org',
'@type': 'WebPage',
'@id': canonical,
name: title,
description,
url: canonical,
inLanguage: 'en',
isPartOf: {
'@type': 'WebSite',
name: siteName,
url: siteBase,
},
primaryImageOfPage: {
'@type': 'ImageObject',
url: seoImage.src,
width: seoImage.width,
height: seoImage.height,
},
},
| const formattedSegment = segment | ||
| .split('-') | ||
| .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) | ||
| .join(' '); |
There was a problem hiding this comment.
This is a nice improvement for formatting breadcrumb labels! However, there's an edge case to consider. If a path segment contains multiple hyphens together (e.g., foo--bar), split('-') will produce empty strings in the array (['foo', '', 'bar']). This will result in extra spaces in the final formatted name (e.g., 'Foo Bar').
To make this more robust, you can add a .filter(Boolean) step to remove any empty parts before mapping.
const formattedSegment = segment
.split('-')
.filter(Boolean)
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(' ');
Motivation
WebPageschema for each rendered page.Description
WebPageobject to thestructuredDataarray withname,description,url,inLanguage,isPartOf, andprimaryImageOfPagefields insrc/layouts/BaseLayout.astro.-, capitalizing each part, and joining with spaces before building theBreadcrumbListentries.structuredDataJsonincludes the newWebPageand updated breadcrumb list so it is emitted into the page head.Testing
bun run check, which executesLint,Unit Tests,Typecheck,Astro Check,Validate JSON, andValidate Glossary, and all checks passed.Codex Task