@intlayer/docs 6.1.4 → 6.1.6-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +1366 -75
  2. package/blog/ar/nextjs-multilingual-seo-comparison.md +364 -0
  3. package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +1288 -72
  4. package/blog/de/nextjs-multilingual-seo-comparison.md +362 -0
  5. package/blog/en/intlayer_with_next-i18next.mdx +431 -0
  6. package/blog/en/intlayer_with_next-intl.mdx +335 -0
  7. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +583 -336
  8. package/blog/en/nextjs-multilingual-seo-comparison.md +360 -0
  9. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +1144 -37
  10. package/blog/en-GB/nextjs-multilingual-seo-comparison.md +360 -0
  11. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +1236 -64
  12. package/blog/es/nextjs-multilingual-seo-comparison.md +363 -0
  13. package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +1142 -75
  14. package/blog/fr/nextjs-multilingual-seo-comparison.md +362 -0
  15. package/blog/hi/nextjs-multilingual-seo-comparison.md +363 -0
  16. package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +1130 -55
  17. package/blog/it/nextjs-multilingual-seo-comparison.md +363 -0
  18. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +1150 -76
  19. package/blog/ja/nextjs-multilingual-seo-comparison.md +362 -0
  20. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +1139 -73
  21. package/blog/ko/nextjs-multilingual-seo-comparison.md +362 -0
  22. package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +1143 -76
  23. package/blog/pt/nextjs-multilingual-seo-comparison.md +362 -0
  24. package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +1150 -74
  25. package/blog/ru/nextjs-multilingual-seo-comparison.md +370 -0
  26. package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  27. package/blog/tr/nextjs-multilingual-seo-comparison.md +362 -0
  28. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +1152 -75
  29. package/blog/zh/nextjs-multilingual-seo-comparison.md +394 -0
  30. package/dist/cjs/generated/blog.entry.cjs +16 -0
  31. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  32. package/dist/cjs/generated/docs.entry.cjs +16 -0
  33. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  34. package/dist/esm/generated/blog.entry.mjs +16 -0
  35. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  36. package/dist/esm/generated/docs.entry.mjs +16 -0
  37. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  38. package/dist/types/generated/blog.entry.d.ts +1 -0
  39. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  40. package/dist/types/generated/docs.entry.d.ts +1 -0
  41. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  42. package/docs/ar/component_i18n.md +186 -0
  43. package/docs/ar/vs_code_extension.md +48 -109
  44. package/docs/de/component_i18n.md +186 -0
  45. package/docs/de/vs_code_extension.md +46 -107
  46. package/docs/en/component_i18n.md +186 -0
  47. package/docs/en/interest_of_intlayer.md +2 -2
  48. package/docs/en/intlayer_with_nextjs_14.md +18 -1
  49. package/docs/en/intlayer_with_nextjs_15.md +18 -1
  50. package/docs/en/vs_code_extension.md +24 -114
  51. package/docs/en-GB/component_i18n.md +186 -0
  52. package/docs/en-GB/vs_code_extension.md +42 -103
  53. package/docs/es/component_i18n.md +182 -0
  54. package/docs/es/vs_code_extension.md +53 -114
  55. package/docs/fr/component_i18n.md +186 -0
  56. package/docs/fr/vs_code_extension.md +50 -111
  57. package/docs/hi/component_i18n.md +186 -0
  58. package/docs/hi/vs_code_extension.md +49 -110
  59. package/docs/it/component_i18n.md +186 -0
  60. package/docs/it/vs_code_extension.md +50 -111
  61. package/docs/ja/component_i18n.md +186 -0
  62. package/docs/ja/vs_code_extension.md +50 -111
  63. package/docs/ko/component_i18n.md +186 -0
  64. package/docs/ko/vs_code_extension.md +48 -109
  65. package/docs/pt/component_i18n.md +186 -0
  66. package/docs/pt/vs_code_extension.md +46 -107
  67. package/docs/ru/component_i18n.md +186 -0
  68. package/docs/ru/vs_code_extension.md +48 -109
  69. package/docs/tr/component_i18n.md +186 -0
  70. package/docs/tr/vs_code_extension.md +54 -115
  71. package/docs/zh/component_i18n.md +186 -0
  72. package/docs/zh/vs_code_extension.md +51 -105
  73. package/package.json +11 -11
  74. package/src/generated/blog.entry.ts +16 -0
  75. package/src/generated/docs.entry.ts +16 -0
@@ -0,0 +1,362 @@
1
+ ---
2
+ createdAt: 2025-09-28
3
+ updatedAt: 2025-09-28
4
+ title: Next.jsにおけるSEOとi18n
5
+ description: next-intl、next-i18next、Intlayerを使ってNext.jsアプリで多言語SEOを設定する方法を学びましょう。
6
+ keywords:
7
+ - Intlayer
8
+ - SEO
9
+ - 国際化
10
+ - Next.js
11
+ - i18n
12
+ - JavaScript
13
+ - React
14
+ - next-intl
15
+ - next-i18next
16
+ slugs:
17
+ - blog
18
+ - blog-seo-i18n-nextjs
19
+ ---
20
+
21
+ # Next.jsにおけるSEOとi18n:翻訳だけでは不十分
22
+
23
+ 開発者が国際化(i18n)を考えるとき、最初の反応はしばしば「コンテンツを翻訳すること」です。しかし、多くの人は国際化の主な目的が、あなたのウェブサイトを世界により見えるようにすることだということを忘れがちです。
24
+ 多言語対応のNext.jsアプリが、検索エンジンに対して異なる言語バージョンのクロールや理解の方法を伝えなければ、あなたの多くの努力は見過ごされてしまうかもしれません。
25
+
26
+ このブログでは、**なぜi18nがSEOの強力な武器となるのか**、そして`next-intl`、`next-i18next`、`Intlayer`を使ってNext.jsで正しく実装する方法を探っていきます。
27
+
28
+ ---
29
+
30
+ ## なぜSEOとi18nが重要なのか
31
+
32
+ 言語を追加することは単なるUXの向上だけではありません。それは**オーガニックな可視性**を高める強力な手段でもあります。理由は以下の通りです:
33
+
34
+ 1. **より良い発見性:** 検索エンジンはローカライズされたバージョンをインデックスし、ユーザーが母国語で検索した際にそれらをランク付けします。
35
+ 2. **重複コンテンツの回避:** 適切なカノニカルタグと代替タグが、クローラーにどのページがどのロケールに属するかを伝えます。
36
+ 3. **より良いUX:** 訪問者はすぐにサイトの適切なバージョンにアクセスできます。
37
+ 4. **競争優位性:** 多言語SEOを適切に実装しているサイトは少ないため、あなたのサイトは際立つことができます。
38
+
39
+ ---
40
+
41
+ ## Next.jsにおける多言語SEOのベストプラクティス
42
+
43
+ すべての多言語アプリが実装すべきチェックリストはこちらです:
44
+
45
+ - **`<head>`内に`hreflang`メタタグを設定する**
46
+ Googleが各言語のバージョンを理解するのに役立ちます。
47
+
48
+ - **翻訳されたすべてのページを`sitemap.xml`にリストアップする**
49
+ `xhtml`スキーマを使用して、クローラーが代替ページを簡単に見つけられるようにします。
50
+
51
+ - **`robots.txt`でプライベート/ローカライズされたルートを除外する**
52
+ 例:`/dashboard`、`/fr/dashboard`、`/es/dashboard`などがインデックスされないようにします。
53
+
54
+ - **ローカライズされたリンクを使用する**
55
+ 例:デフォルトの`/about`ではなく、`<a href="/fr/about">À propos</a>`のようにリンクします。
56
+
57
+ これらは簡単なステップですが、スキップすると可視性を失う可能性があります。
58
+
59
+ ---
60
+
61
+ ## 実装例
62
+
63
+ 開発者はしばしばロケール間でページを適切に参照することを忘れがちなので、さまざまなライブラリでどのように機能するかを見てみましょう。
64
+
65
+ ### **next-intl**
66
+
67
+ <Tabs>
68
+ <TabItem label="next-intl">
69
+
70
+ ```tsx fileName="src/app/[locale]/about/layout.tsx"
71
+ import type { Metadata } from "next";
72
+ import { locales, defaultLocale } from "@/i18n";
73
+ import { getTranslations, unstable_setRequestLocale } from "next-intl/server";
74
+
75
+ function localizedPath(locale: string, path: string) {
76
+ return locale === defaultLocale ? path : `/${locale}${path}`;
77
+ }
78
+
79
+ export async function generateMetadata({
80
+ params,
81
+ }: {
82
+ params: { locale: string };
83
+ }): Promise<Metadata> {
84
+ const { locale } = params;
85
+ const t = await getTranslations({ locale, namespace: "about" });
86
+
87
+ const url = "/about";
88
+ const languages = Object.fromEntries(
89
+ locales.map((l) => [l, localizedPath(l, url)])
90
+ );
91
+
92
+ return {
93
+ title: t("title"),
94
+ description: t("description"),
95
+ alternates: {
96
+ canonical: localizedPath(locale, url),
97
+ languages: { ...languages, "x-default": url },
98
+ },
99
+ };
100
+ }
101
+
102
+ // ... ページの残りのコード
103
+ ```
104
+
105
+ ```tsx fileName="src/app/sitemap.ts"
106
+ import type { MetadataRoute } from "next";
107
+ import { locales, defaultLocale } from "@/i18n";
108
+
109
+ const origin = "https://example.com";
110
+
111
+ const formatterLocalizedPath = (locale: string, path: string) =>
112
+ locale === defaultLocale ? `${origin}${path}` : `${origin}/${locale}${path}`;
113
+
114
+ export default function sitemap(): MetadataRoute.Sitemap {
115
+ const aboutLanguages = Object.fromEntries(
116
+ locales.map((l) => [l, formatterLocalizedPath(l, "/about")])
117
+ );
118
+
119
+ return [
120
+ {
121
+ url: formatterLocalizedPath(defaultLocale, "/about"),
122
+ lastModified: new Date(),
123
+ changeFrequency: "monthly", // 毎月の更新頻度
124
+ priority: 0.7, // 優先度
125
+ alternates: { languages: aboutLanguages }, // 言語別の代替URL
126
+ },
127
+ ];
128
+ }
129
+ ```
130
+
131
+ ```tsx fileName="src/app/robots.ts"
132
+ import type { MetadataRoute } from "next";
133
+ import { locales, defaultLocale } from "@/i18n";
134
+
135
+ const origin = "https://example.com";
136
+ const withAllLocales = (path: string) => [
137
+ path,
138
+ ...locales.filter((l) => l !== defaultLocale).map((l) => `/${l}${path}`), // デフォルトロケール以外のパスを追加
139
+ ];
140
+
141
+ export default function robots(): MetadataRoute.Robots {
142
+ const disallow = [
143
+ ...withAllLocales("/dashboard"), // /dashboard へのアクセス禁止
144
+ ...withAllLocales("/admin"), // /admin へのアクセス禁止
145
+ ];
146
+
147
+ return {
148
+ rules: { userAgent: "*", allow: ["/"], disallow },
149
+ host: origin,
150
+ sitemap: `${origin}/sitemap.xml`,
151
+ };
152
+ }
153
+ ```
154
+
155
+ ### **next-i18next**
156
+
157
+ </TabItem>
158
+ <TabItem label="next-i18next">
159
+
160
+ ```ts fileName="i18n.config.ts"
161
+ export const locales = ["en", "fr"] as const;
162
+ export type Locale = (typeof locales)[number];
163
+ export const defaultLocale: Locale = "en";
164
+
165
+ /** デフォルトロケールでない場合はロケールをパスの前に付ける */
166
+ export function localizedPath(locale: string, path: string) {
167
+ return locale === defaultLocale ? path : `/${locale}${path}`;
168
+ }
169
+
170
+ /** 絶対URLヘルパー */
171
+ const ORIGIN = "https://example.com";
172
+ export function abs(locale: string, path: string) {
173
+ return `${ORIGIN}${localizedPath(locale, path)}`;
174
+ }
175
+ ```
176
+
177
+ ```tsx fileName="src/app/[locale]/about/layout.tsx"
178
+ import type { Metadata } from "next";
179
+ import { locales, defaultLocale, localizedPath } from "@/i18n.config";
180
+
181
+ export async function generateMetadata({
182
+ params,
183
+ }: {
184
+ params: { locale: string };
185
+ }): Promise<Metadata> {
186
+ const { locale } = params;
187
+
188
+ // 正しいJSONファイルを動的にインポートする
189
+ const messages = (await import(`@/../public/locales/${locale}/about.json`))
190
+ .default;
191
+
192
+ const languages = Object.fromEntries(
193
+ locales.map((l) => [l, localizedPath(l, "/about")])
194
+ );
195
+
196
+ return {
197
+ title: messages.title,
198
+ description: messages.description,
199
+ alternates: {
200
+ canonical: localizedPath(locale, "/about"),
201
+ languages: { ...languages, "x-default": "/about" },
202
+ },
203
+ };
204
+ }
205
+
206
+ export default async function AboutPage() {
207
+ return <h1>About</h1>;
208
+ }
209
+ ```
210
+
211
+ ```ts fileName="src/app/sitemap.ts"
212
+ import type { MetadataRoute } from "next";
213
+ import { locales, defaultLocale, abs } from "@/i18n.config";
214
+
215
+ export default function sitemap(): MetadataRoute.Sitemap {
216
+ const languages = Object.fromEntries(
217
+ locales.map((l) => [l, abs(l, "/about")])
218
+ );
219
+ return [
220
+ {
221
+ url: abs(defaultLocale, "/about"),
222
+ lastModified: new Date(),
223
+ changeFrequency: "monthly",
224
+ priority: 0.7,
225
+ alternates: { languages },
226
+ },
227
+ ];
228
+ }
229
+ ```
230
+
231
+ ```ts fileName="src/app/robots.ts"
232
+ import type { MetadataRoute } from "next";
233
+ import { locales, defaultLocale, localizedPath } from "@/i18n.config";
234
+
235
+ const ORIGIN = "https://example.com";
236
+
237
+ const expandAllLocales = (path: string) => [
238
+ localizedPath(defaultLocale, path),
239
+ ...locales
240
+ .filter((l) => l !== defaultLocale)
241
+ .map((l) => localizedPath(l, path)),
242
+ ];
243
+
244
+ export default function robots(): MetadataRoute.Robots {
245
+ const disallow = [
246
+ ...expandAllLocales("/dashboard"),
247
+ ...expandAllLocales("/admin"),
248
+ ];
249
+
250
+ return {
251
+ rules: { userAgent: "*", allow: ["/"], disallow },
252
+ host: ORIGIN,
253
+ sitemap: `${ORIGIN}/sitemap.xml`,
254
+ };
255
+ }
256
+ ```
257
+
258
+ ### **Intlayer**
259
+
260
+ </TabItem>
261
+ <TabItem label="intlayer">
262
+
263
+ ````typescript fileName="src/app/[locale]/about/layout.tsx"
264
+ import { getIntlayer, getMultilingualUrls } from "intlayer";
265
+ import type { Metadata } from "next";
266
+ import type { LocalPromiseParams } from "next-intlayer";
267
+
268
+ export const generateMetadata = async ({
269
+ params,
270
+ }: LocalPromiseParams): Promise<Metadata> => {
271
+ const { locale } = await params;
272
+
273
+ const metadata = getIntlayer("page-metadata", locale);
274
+
275
+ /**
276
+ * 各ロケールのすべてのURLを含むオブジェクトを生成します。
277
+ *
278
+ * 例:
279
+ * ```ts
280
+ * getMultilingualUrls('/about');
281
+ *
282
+ * // 戻り値
283
+ * // {
284
+ * // en: '/about',
285
+ * // fr: '/fr/about',
286
+ * // es: '/es/about',
287
+ * // }
288
+ * ```
289
+ */
290
+ const multilingualUrls = getMultilingualUrls("/about");
291
+
292
+ return {
293
+ ...metadata,
294
+ alternates: {
295
+ canonical: multilingualUrls[locale as keyof typeof multilingualUrls],
296
+ languages: { ...multilingualUrls, "x-default": "/about" },
297
+ },
298
+ };
299
+ };
300
+
301
+ // ... ページの残りのコード
302
+ ````
303
+
304
+ ```tsx fileName="src/app/sitemap.ts"
305
+ import { getMultilingualUrls } from "intlayer";
306
+ import type { MetadataRoute } from "next";
307
+
308
+ const sitemap = (): MetadataRoute.Sitemap => [
309
+ {
310
+ url: "https://example.com/about",
311
+ alternates: {
312
+ languages: { ...getMultilingualUrls("https://example.com/about") },
313
+ },
314
+ },
315
+ ];
316
+ ```
317
+
318
+ ```tsx fileName="src/app/robots.ts"
319
+ import { getMultilingualUrls } from "intlayer";
320
+ import type { MetadataRoute } from "next";
321
+
322
+ // すべての多言語URLを取得する関数
323
+ const getAllMultilingualUrls = (urls: string[]) =>
324
+ urls.flatMap((url) => Object.values(getMultilingualUrls(url)) as string[]);
325
+
326
+ // robots.txtの設定を生成
327
+ const robots = (): MetadataRoute.Robots => ({
328
+ rules: {
329
+ userAgent: "*", // すべてのユーザーエージェントに適用
330
+ allow: ["/"], // ルートパスは許可
331
+ disallow: getAllMultilingualUrls(["/dashboard"]), // /dashboard以下の多言語URLはクロール禁止
332
+ },
333
+ host: "https://example.com", // ホスト名
334
+ sitemap: `https://example.com/sitemap.xml`, // サイトマップのURL
335
+ });
336
+
337
+ export default robots;
338
+ ```
339
+
340
+ > Intlayerは、サイトマップ用の多言語URLを生成するための`getMultilingualUrls`関数を提供しています。
341
+
342
+ </TabItem>
343
+ </Tabs>
344
+
345
+ ---
346
+
347
+ ## 結論
348
+
349
+ Next.jsでi18nを正しく実装することは、単にテキストを翻訳するだけでなく、検索エンジンやユーザーがどのバージョンのコンテンツを提供すべきかを正確に認識できるようにすることです。
350
+ hreflang、サイトマップ、robotsルールの設定が、翻訳を真のSEO価値に変える鍵となります。
351
+
352
+ next-intlやnext-i18nextは、この連携を実現するための堅実な方法を提供しますが、通常はロケール間で一貫性を保つために多くの手動設定が必要です。
353
+
354
+ ここでIntlayerが真価を発揮します:
355
+
356
+ getMultilingualUrlsのような組み込みヘルパーが付属しており、hreflang、サイトマップ、robotsの統合をほぼ手間なく実現します。
357
+
358
+ メタデータはJSONファイルやカスタムユーティリティに散在するのではなく、一元管理されます。
359
+
360
+ Next.jsのために最初から設計されているため、設定のデバッグに費やす時間を減らし、リリースに集中できます。
361
+
362
+ 単に翻訳するだけでなく、多言語SEOをスムーズに拡大することを目指すなら、Intlayerは最もクリーンで将来性のあるセットアップを提供します。