Skip to content

Enhance SEO structured data in BaseLayout#407

Merged
zz-plant merged 1 commit into
mainfrom
codex/seo-optimize-repository-pages
Jan 15, 2026
Merged

Enhance SEO structured data in BaseLayout#407
zz-plant merged 1 commit into
mainfrom
codex/seo-optimize-repository-pages

Conversation

@zz-plant

Copy link
Copy Markdown
Owner

Motivation

  • Improve page-level SEO and rich results by emitting explicit WebPage schema for each rendered page.
  • Make breadcrumb labels in structured data more human-readable by normalizing hyphenated path segments.

Description

  • Add a WebPage object to the structuredData array with name, description, url, inLanguage, isPartOf, and primaryImageOfPage fields in src/layouts/BaseLayout.astro.
  • Normalize breadcrumb segment labels by splitting on -, capitalizing each part, and joining with spaces before building the BreadcrumbList entries.
  • Ensure the final structuredDataJson includes the new WebPage and updated breadcrumb list so it is emitted into the page head.

Testing

  • Ran the repository checks with bun run check, which executes Lint, Unit Tests, Typecheck, Astro Check, Validate JSON, and Validate Glossary, and all checks passed.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 15, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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

  • Enhanced SEO Structured Data: An explicit 'WebPage' schema object has been added to the structured data for each rendered page, providing richer context for search engines and improving potential rich results.
  • Improved Breadcrumb Readability: The logic for generating breadcrumb labels in structured data has been updated to normalize hyphenated path segments, making them more human-readable.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@zz-plant zz-plant merged commit 858ad8e into main Jan 15, 2026
1 of 2 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +58 to +76
{
'@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,
},
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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,
    },
  },

Comment on lines +90 to +93
const formattedSegment = segment
.split('-')
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(' ');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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(' ');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant