Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Negotiation & hreflang Support #1577

Closed
anaclumos opened this issue Nov 26, 2024 · 5 comments
Closed

Content Negotiation & hreflang Support #1577

anaclumos opened this issue Nov 26, 2024 · 5 comments
Labels
enhancement New feature or request unconfirmed Needs triage.

Comments

@anaclumos
Copy link

Is your feature request related to a problem? Please describe.

I've noticed there doesn't seem to be a support for HTTP Content Negotiation and hreflang support.

Describe the solution you'd like

An automated way of HTTP Content Negotiation and hreflang support

Describe alternatives you've considered

N/A

@anaclumos anaclumos added enhancement New feature or request unconfirmed Needs triage. labels Nov 26, 2024
@amannn
Copy link
Owner

amannn commented Nov 26, 2024

Not sure I can follow, can you provide some more details?

Some references:

  1. The middleware uses the accept-language header to negotiate a matching locale (among other aspects)
  2. The middleware sets the link header to link together pages in different languages.
  3. Link sets an hreflang in case you're linking to another locale. When you're linking to a page that uses the current locale, no hreflang is necessary.

@anaclumos
Copy link
Author

Sorry for checking this late -- does next-intl set link tags in <head> like:

<link rel="alternate" href="https://yourdomain.com/be/" hreflang="fr-be" />

I was mainly talking about this!

For example, docusaurus sets:

image

@amannn
Copy link
Owner

amannn commented Dec 10, 2024

Yep, next-intl sets these links via the link header on the response:

Screenshot 2024-12-10 at 13 27 40

Whether you're using an HTML tag or a response header is equal from the perspective of a search engine.

Just one note though: Next.js 15 broke the link response header if you're using next/font or next/image. I've set up a PR to fix this: vercel/next.js#73431. So if you use these features, you might want to wait with upgrading to Next.js 15 until this is merged :).

Hope this helps!

@anaclumos
Copy link
Author

Fabulous — I just sent a one-time sponsor as you went deeper even to submit a PR! Incredibly thankful. Please get something to treat yourself, maybe a cup of coffee 😁

@amannn
Copy link
Owner

amannn commented Dec 10, 2024

You're one of the absolutely nicest people running around on the internet—many thanks Sunghyun! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants