feat: 英語版 /en ルートを追加(別URL・lang=en・hreflang相互リンク) (#48)#49
Merged
Conversation
route group で root layout を ja/en に分割し、英語圏SEOを本格対応。
JA は今まで通り root /、英語版を /en に追加。
- app/(ja)/{layout,page}.tsx … URL /(html lang=ja)
- app/(en)/{layout.tsx, en/page.tsx} … URL /en(html lang=en, forcedLang=en)
- lib/seo.ts … 言語別 metadata/JSON-LD を集約。hreflang(ja/en/x-default)・
canonical・og:locale/alternateLocale・inLanguage[ja,en]・alternateName
- components/HomePage.tsx … Home 本体を共有化(両ルートで描画)
- lib/i18n.tsx … I18nProvider に forcedLang(/en は en 固定で auto-detect 抑止)
- components/LangToggle.tsx … 2ルート間ナビ(JA→/・EN→/en、選択を保存)
- 旧 app/{layout,page}.tsx は削除
build で out/index.html(lang=ja)・out/en.html(lang=en) 生成、両者に正しい
hreflang/canonical/OG。lint・test(24) green。dev で /・/en を実機確認。
Refs #48
Deploying machigai-salad with
|
| Latest commit: |
6a28600
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1347d4f4.machigai-salad.pages.dev |
| Branch Preview URL: | https://seo-en-route.machigai-salad.pages.dev |
- README: 日英対応を /(ja)+ /en(en, hreflang)に更新 - architecture.md: route group による2 root layout 構成・lib/seo.ts・ forcedLang・LangToggle ナビ化の節を追加、実装済みに SEO土台と /en を追記
- sitemap.ts: / と /en の2エントリ化、各エントリに hreflang alternates
(英語ページをクロール対象に明示。should 指摘)
- seo.ts buildJsonLd: url の冗長な三項を ${siteUrl}${PATH[lang]} に簡略化(nit)
This was referenced Jun 15, 2026
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.
概要
英語圏SEOの本格対応。同一URL制約を外し、JA は今まで通り
/、英語版を/enに追加。別URL・
<html lang="en">・hreflang 相互リンクで、英語の検索でも拾われる土台にする。仕組み
Next の route group で root layout を2つに分けた(
<html lang>をルート別に正しく静的出力するため):app/(ja)/{layout,page}.tsx→ URL/(<html lang="ja">・JA メタ)app/(en)/{layout.tsx, en/page.tsx}→ URL/en(<html lang="en">・EN メタ・forcedLang="en")components/HomePage.tsxに本体を共有化、両ルートで描画lib/seo.tsに言語別 metadata/JSON-LD を集約SEO 出力(ビルド実物で確認)
/(out/index.html)/en(out/en.html)//en/, en=/en, x-default=/(両ページに)UX 設計(要レビュー)
/、EN→/en)。クリック時に選択を localStorage 保存し、/の auto-detect が選択を尊重する/は従来挙動を維持(初回訪問は navigator から自動判定、英語ユーザーは/でも英語UI)。/enは常に英語固定検証
npm run build成功(/と/enを静的生成)/は日本語UI・/enは英語UIで描画(JA字幕が/enに出ないことも確認)/と/enを実機スクショ確認正直な限界
/enの本文を英語で厚くする等は別途Refs #48