Skip to content

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Sep 11, 2025

Remove these invalid HTML tags from the output when context.site is unset:

  • <link rel="canonical"/> with missing href
  • <meta property="og:url"/> with missing content

Copy link

changeset-bot bot commented Sep 11, 2025

🦋 Changeset detected

Latest commit: 7319a41

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Sep 11, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 7319a41
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/68c4667116a6e50008148c89
😎 Deploy Preview https://deploy-preview-3420--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Sep 11, 2025
@astrobot-houston
Copy link
Contributor

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@andersk andersk force-pushed the invalid-canonical branch 2 times, most recently from 4822238 to 40e2fd2 Compare September 11, 2025 22:19
Copy link
Contributor

@trueberryless trueberryless left a comment

Choose a reason for hiding this comment

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

Thank you very much for this and all the other awesome PRs.

These changes look good to me. While I couldn't find a resource stating that those tags are invalid without the content attribute, the semantic meaning of those tags is empty.

Here are the resources I found that only say how the tag is intended:

@andersk
Copy link
Contributor Author

andersk commented Sep 12, 2025

Adjusted as suggested, thanks.

The specification for <link> href says:

One or both of the href or imagesrcset attributes must be present.

For <meta> content, since OpenGraph is based on RDFa, here’s the relevant specification:

If the RDFa @property attribute is present on the meta element, neither the @name, @http-equiv, nor @charset attributes are required and the @content attribute MUST be specified.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

It would be good to write some tests for this change to make sure we don’t accidentally regress. These can probably go in packages/starlight/__tests__/head/head.test.ts — we might need to update the getRouteDataTestContext and getTestHead helpers to allow for testing with site not set.

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

Labels

🌟 core Changes to Starlight’s main package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants