Skip to content

Add x-default meta tag for multilingual sites#3845

Open
delucis wants to merge 1 commit intomainfrom
chris/hreflang-x-default
Open

Add x-default meta tag for multilingual sites#3845
delucis wants to merge 1 commit intomainfrom
chris/hreflang-x-default

Conversation

@delucis
Copy link
Copy Markdown
Member

@delucis delucis commented Apr 22, 2026

Description

  • This PR adds an additional <link rel="alternate" hreflang="x-default" href="..."> meta tag to the existing hreflang alternates in multilingual sites.
  • Previously I’d avoided this due to Google’s docs on x-default saying that “it was designed for language selector pages”.
  • But a (I think recent?) update to that page says you can use any page and I noticed that @jdevalk’s SEO tools for Astro use x-default more liberally. Given his many years of SEO experience, I’m guessing that’s a sign this is a safe approach.

Context

One reason for experimenting with this is to see if it helps with Starlight’s use of duplicate content. In multilingual Starlight sites that are not fully translated, the default language’s content gets reused to provide readers with something without leaving their locale. This leads to situations like

  • example.com/en/intro/ — default locale content
  • example.com/fr/intro/ — translated content
  • example.com/de/intro/ — not translated, so reuses /en/ content (but with German UI for navigation etc.)

We’ve heard some reports that this reuse causes issues for search engines and can confuse them into using the non-default locale URL, so e.g. in this case a user searching in English gets suggested the /de/ URL.

Factors:

  • each page has <html lang="en/fr/de"> to indicate locale
  • each page contains hreflang alternates
  • each page is its own canonical URL, including pages with duplicate content, because UI is localized
  • for pages reusing content, the content embedded in the page has a lang="en" (or whatever the default locale is) attribute

I’m curious to see if x-default helps at all here as a signal in these cases.

The more extreme fix (and very likely to work) would be to use canonical to point back to the default locale for pages containing fallback content. However, this can have other unintended consequences. For example, site search indexers like Algolia skip indexing non-canonical pages by default, essentially removing this content if your language is not translated yet. So this change is an easier first step.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: 4ee3ded

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 Minor

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

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 4ee3ded
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/69e8f466e26886000832b2f7
😎 Deploy Preview https://deploy-preview-3845--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 (no change 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 Apr 22, 2026
@delucis delucis added the 🌟 minor Change that triggers a minor release label Apr 22, 2026
@astrobot-houston
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
/index.html 5.61 KB (0%)
/_astro/*.js 26.03 KB (0%)
/_astro/*.css 16.05 KB (0%)

@jdevalk
Copy link
Copy Markdown

jdevalk commented Apr 22, 2026

Yeah good change I think.

Copy link
Copy Markdown
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

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

I'm certainly not as experimented as Joost, but as discussed in withastro/docs#13361 I think It's worth a try!

@delucis delucis added this to the v0.39 milestone Apr 22, 2026
@matthewp
Copy link
Copy Markdown
Contributor

Explanation sounds reasonable, but I'm not familiar with this property fwiw.

Copy link
Copy Markdown
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.

I mean the Google docs still state that x-default was designed for language select pages, but I'm in favour of trying it out.

Do you think adding some kind of comment in the code linking to the Google docs or stating that we want to try it out would make sense? I wouls just like to avoid leaving a head link in there in the long-term where we forgot why it was added in the first place... 🤔 So maybe linking to this PR would also make sense...

@delucis delucis added the ✅ approved Pull requests that have been approved and are ready to merge when next cutting a release label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅ approved Pull requests that have been approved and are ready to merge when next cutting a release 🌟 core Changes to Starlight’s main package 🌟 minor Change that triggers a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants