Repository navigation
Fix language switcher broken at root path - #26
Merged
Merged
Conversation
- Nav.tsx: When pathname is "/", generate "/${locale}" directly instead
of trying to replace "/${lang}" which doesn't exist in "/"
- layout.tsx: Move OrganizationJsonLd and WebsiteJsonLd from <body> to
explicit <head> element, which is more semantically correct per HTML spec
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
echobell-one | 874bc40 | Commit Preview URL Branch Preview URL |
Apr 18 2026, 04:10 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/.usePathname()returns/at the root (because middleware rewrites/→/enwithout changing the browser URL), sopathname.replace("/en", "/de")found nothing to replace and all language options linked back to/. Fix: whenpathname === "/", generate/${locale}directly.OrganizationJsonLdandWebsiteJsonLdfrom<body>to an explicit<head>element — more semantically correct per HTML spec (JSON-LD in<head>is the conventional placement).SEO note
The existing setup where
/rewrites to/en(no redirect) is intentional for social crawlers. The canonical tag on the home page correctly points to/en, so Google consolidates signals — no duplicate content issue.Test plan
http://localhost:3000/and open the language switcher — verify each language navigates to the correct localized root (e.g./zh,/de)http://localhost:3000/en/docsand verify the language switcher still works as before<head>🤖 Generated with Claude Code