@intlayer/docs 6.1.4 → 6.1.5

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 (35) hide show
  1. package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +1135 -75
  2. package/blog/ar/nextjs-multilingual-seo-comparison.md +364 -0
  3. package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +1139 -72
  4. package/blog/de/nextjs-multilingual-seo-comparison.md +362 -0
  5. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +224 -240
  6. package/blog/en/nextjs-multilingual-seo-comparison.md +360 -0
  7. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +1134 -37
  8. package/blog/en-GB/nextjs-multilingual-seo-comparison.md +360 -0
  9. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +1122 -64
  10. package/blog/es/nextjs-multilingual-seo-comparison.md +363 -0
  11. package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +1132 -75
  12. package/blog/fr/nextjs-multilingual-seo-comparison.md +362 -0
  13. package/blog/hi/nextjs-multilingual-seo-comparison.md +363 -0
  14. package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +1120 -55
  15. package/blog/it/nextjs-multilingual-seo-comparison.md +363 -0
  16. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +1140 -76
  17. package/blog/ja/nextjs-multilingual-seo-comparison.md +362 -0
  18. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +1129 -73
  19. package/blog/ko/nextjs-multilingual-seo-comparison.md +362 -0
  20. package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +1133 -76
  21. package/blog/pt/nextjs-multilingual-seo-comparison.md +362 -0
  22. package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +1142 -74
  23. package/blog/ru/nextjs-multilingual-seo-comparison.md +370 -0
  24. package/blog/tr/nextjs-multilingual-seo-comparison.md +362 -0
  25. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +1142 -75
  26. package/blog/zh/nextjs-multilingual-seo-comparison.md +394 -0
  27. package/dist/cjs/generated/blog.entry.cjs +16 -0
  28. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  29. package/dist/esm/generated/blog.entry.mjs +16 -0
  30. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  31. package/dist/types/generated/blog.entry.d.ts +1 -0
  32. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  33. package/docs/en/interest_of_intlayer.md +2 -2
  34. package/package.json +10 -10
  35. package/src/generated/blog.entry.ts +16 -0
@@ -0,0 +1,363 @@
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.js में `next-intl`, `next-i18next`, और `Intlayer` के साथ सही तरीके से कैसे लागू किया जाए।
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
+ // स्थानीयकृत पथ प्राप्त करने का फ़ंक्शन
76
+ function localizedPath(locale: string, path: string) {
77
+ return locale === defaultLocale ? path : `/${locale}${path}`;
78
+ }
79
+
80
+ export async function generateMetadata({
81
+ params,
82
+ }: {
83
+ params: { locale: string };
84
+ }): Promise<Metadata> {
85
+ const { locale } = params;
86
+ const t = await getTranslations({ locale, namespace: "about" });
87
+
88
+ const url = "/about";
89
+ const languages = Object.fromEntries(
90
+ locales.map((l) => [l, localizedPath(l, url)])
91
+ );
92
+
93
+ return {
94
+ title: t("title"),
95
+ description: t("description"),
96
+ alternates: {
97
+ canonical: localizedPath(locale, url),
98
+ languages: { ...languages, "x-default": url },
99
+ },
100
+ };
101
+ }
102
+
103
+ // ... पृष्ठ कोड का बाकी हिस्सा
104
+ ```
105
+
106
+ ```tsx fileName="src/app/sitemap.ts"
107
+ import type { MetadataRoute } from "next";
108
+ import { locales, defaultLocale } from "@/i18n";
109
+
110
+ const origin = "https://example.com";
111
+
112
+ const formatterLocalizedPath = (locale: string, path: string) =>
113
+ locale === defaultLocale ? `${origin}${path}` : `${origin}/${locale}${path}`;
114
+
115
+ export default function sitemap(): MetadataRoute.Sitemap {
116
+ const aboutLanguages = Object.fromEntries(
117
+ locales.map((l) => [l, formatterLocalizedPath(l, "/about")])
118
+ );
119
+
120
+ return [
121
+ {
122
+ url: formatterLocalizedPath(defaultLocale, "/about"),
123
+ lastModified: new Date(),
124
+ changeFrequency: "monthly",
125
+ priority: 0.7,
126
+ alternates: { languages: aboutLanguages },
127
+ },
128
+ ];
129
+ }
130
+ ```
131
+
132
+ ```tsx fileName="src/app/robots.ts"
133
+ import type { MetadataRoute } from "next";
134
+ import { locales, defaultLocale } from "@/i18n";
135
+
136
+ const origin = "https://example.com";
137
+ const withAllLocales = (path: string) => [
138
+ path,
139
+ ...locales.filter((l) => l !== defaultLocale).map((l) => `/${l}${path}`),
140
+ ];
141
+
142
+ export default function robots(): MetadataRoute.Robots {
143
+ const disallow = [
144
+ ...withAllLocales("/dashboard"),
145
+ ...withAllLocales("/admin"),
146
+ ];
147
+
148
+ return {
149
+ rules: { userAgent: "*", allow: ["/"], disallow },
150
+ host: origin,
151
+ sitemap: `${origin}/sitemap.xml`,
152
+ };
153
+ }
154
+ ```
155
+
156
+ ### **next-i18next**
157
+
158
+ </TabItem>
159
+ <TabItem label="next-i18next">
160
+
161
+ ```ts fileName="i18n.config.ts"
162
+ export const locales = ["en", "fr"] as const;
163
+ export type Locale = (typeof locales)[number];
164
+ export const defaultLocale: Locale = "en";
165
+
166
+ /** डिफ़ॉल्ट लोकल के अलावा लोकल के साथ पथ को प्रीफिक्स करें */
167
+ export function localizedPath(locale: string, path: string) {
168
+ return locale === defaultLocale ? path : `/${locale}${path}`;
169
+ }
170
+
171
+ /** पूर्ण URL सहायक */
172
+ const ORIGIN = "https://example.com";
173
+ export function abs(locale: string, path: string) {
174
+ return `${ORIGIN}${localizedPath(locale, path)}`;
175
+ }
176
+ ```
177
+
178
+ ```tsx fileName="src/app/[locale]/about/layout.tsx"
179
+ import type { Metadata } from "next";
180
+ import { locales, defaultLocale, localizedPath } from "@/i18n.config";
181
+
182
+ export async function generateMetadata({
183
+ params,
184
+ }: {
185
+ params: { locale: string };
186
+ }): Promise<Metadata> {
187
+ const { locale } = params;
188
+
189
+ // सही JSON फ़ाइल को गतिशील रूप से आयात करें
190
+ const messages = (await import(`@/../public/locales/${locale}/about.json`))
191
+ .default;
192
+
193
+ const languages = Object.fromEntries(
194
+ locales.map((l) => [l, localizedPath(l, "/about")])
195
+ );
196
+
197
+ return {
198
+ title: messages.title,
199
+ description: messages.description,
200
+ alternates: {
201
+ canonical: localizedPath(locale, "/about"),
202
+ languages: { ...languages, "x-default": "/about" },
203
+ },
204
+ };
205
+ }
206
+
207
+ export default async function AboutPage() {
208
+ return <h1>About</h1>;
209
+ }
210
+ ```
211
+
212
+ ```ts fileName="src/app/sitemap.ts"
213
+ import type { MetadataRoute } from "next";
214
+ import { locales, defaultLocale, abs } from "@/i18n.config";
215
+
216
+ export default function sitemap(): MetadataRoute.Sitemap {
217
+ const languages = Object.fromEntries(
218
+ locales.map((l) => [l, abs(l, "/about")])
219
+ );
220
+ return [
221
+ {
222
+ url: abs(defaultLocale, "/about"),
223
+ lastModified: new Date(),
224
+ changeFrequency: "monthly",
225
+ priority: 0.7,
226
+ alternates: { languages },
227
+ },
228
+ ];
229
+ }
230
+ ```
231
+
232
+ ```ts fileName="src/app/robots.ts"
233
+ import type { MetadataRoute } from "next";
234
+ import { locales, defaultLocale, localizedPath } from "@/i18n.config";
235
+
236
+ const ORIGIN = "https://example.com";
237
+
238
+ const expandAllLocales = (path: string) => [
239
+ localizedPath(defaultLocale, path),
240
+ ...locales
241
+ .filter((l) => l !== defaultLocale)
242
+ .map((l) => localizedPath(l, path)),
243
+ ];
244
+
245
+ export default function robots(): MetadataRoute.Robots {
246
+ const disallow = [
247
+ ...expandAllLocales("/dashboard"),
248
+ ...expandAllLocales("/admin"),
249
+ ];
250
+
251
+ return {
252
+ rules: { userAgent: "*", allow: ["/"], disallow },
253
+ host: ORIGIN,
254
+ sitemap: `${ORIGIN}/sitemap.xml`,
255
+ };
256
+ }
257
+ ```
258
+
259
+ ### **Intlayer**
260
+
261
+ </TabItem>
262
+ <TabItem label="intlayer">
263
+
264
+ ````typescript fileName="src/app/[locale]/about/layout.tsx"
265
+ import { getIntlayer, getMultilingualUrls } from "intlayer";
266
+ import type { Metadata } from "next";
267
+ import type { LocalPromiseParams } from "next-intlayer";
268
+
269
+ export const generateMetadata = async ({
270
+ params,
271
+ }: LocalPromiseParams): Promise<Metadata> => {
272
+ const { locale } = await params;
273
+
274
+ const metadata = getIntlayer("page-metadata", locale);
275
+
276
+ /**
277
+ * प्रत्येक लोकल के लिए सभी URL वाले ऑब्जेक्ट को जनरेट करता है।
278
+ *
279
+ * उदाहरण:
280
+ * ```ts
281
+ * getMultilingualUrls('/about');
282
+ *
283
+ * // रिटर्न करता है
284
+ * // {
285
+ * // en: '/about',
286
+ * // fr: '/fr/about',
287
+ * // es: '/es/about',
288
+ * // }
289
+ * ```
290
+ */
291
+ const multilingualUrls = getMultilingualUrls("/about");
292
+
293
+ return {
294
+ ...metadata,
295
+ alternates: {
296
+ canonical: multilingualUrls[locale as keyof typeof multilingualUrls],
297
+ languages: { ...multilingualUrls, "x-default": "/about" },
298
+ },
299
+ };
300
+ };
301
+
302
+ // ... पेज कोड का बाकी हिस्सा
303
+ ````
304
+
305
+ ```tsx fileName="src/app/sitemap.ts"
306
+ import { getMultilingualUrls } from "intlayer";
307
+ import type { MetadataRoute } from "next";
308
+
309
+ const sitemap = (): MetadataRoute.Sitemap => [
310
+ {
311
+ url: "https://example.com/about",
312
+ alternates: {
313
+ languages: { ...getMultilingualUrls("https://example.com/about") },
314
+ },
315
+ },
316
+ ];
317
+ ```
318
+
319
+ ```tsx fileName="src/app/robots.ts"
320
+ import { getMultilingualUrls } from "intlayer";
321
+ import type { MetadataRoute } from "next";
322
+
323
+ // सभी मल्टीलिंगुअल URL को एकत्रित करता है
324
+ const getAllMultilingualUrls = (urls: string[]) =>
325
+ urls.flatMap((url) => Object.values(getMultilingualUrls(url)) as string[]);
326
+
327
+ // रोबोट्स नियम सेट करता है
328
+ const robots = (): MetadataRoute.Robots => ({
329
+ rules: {
330
+ userAgent: "*", // सभी यूजर एजेंट्स के लिए नियम
331
+ allow: ["/"], // अनुमति प्राप्त पथ
332
+ disallow: getAllMultilingualUrls(["/dashboard"]), // निषिद्ध पथ
333
+ },
334
+ host: "https://example.com",
335
+ sitemap: `https://example.com/sitemap.xml`,
336
+ });
337
+
338
+ export default robots;
339
+ ```
340
+
341
+ > Intlayer आपके साइटमैप के लिए मल्टीलिंगुअल URL जनरेट करने के लिए `getMultilingualUrls` फ़ंक्शन प्रदान करता है।
342
+
343
+ </TabItem>
344
+ </Tabs>
345
+
346
+ ---
347
+
348
+ ## निष्कर्ष
349
+
350
+ Next.js में i18n को सही तरीके से लागू करना केवल टेक्स्ट का अनुवाद करने के बारे में नहीं है, बल्कि यह सुनिश्चित करने के बारे में है कि सर्च इंजन और उपयोगकर्ता ठीक उसी संस्करण को जानें जो आपकी सामग्री का सर्वर करना है।
351
+ hreflang, साइटमैप, और रोबोट्स नियम सेट करना वह है जो अनुवादों को वास्तविक SEO मूल्य में बदल देता है।
352
+
353
+ जबकि next-intl और next-i18next आपको इसे सेटअप करने के ठोस तरीके देते हैं, वे आमतौर पर स्थानीय संस्करणों के बीच संगति बनाए रखने के लिए बहुत मैनुअल सेटअप की आवश्यकता होती है।
354
+
355
+ यहीं पर Intlayer वास्तव में चमकता है:
356
+
357
+ यह getMultilingualUrls जैसे बिल्ट-इन हेल्पर्स के साथ आता है, जो hreflang, साइटमैप, और रोबोट्स इंटीग्रेशन को लगभग बिना किसी प्रयास के बनाता है।
358
+
359
+ मेटाडेटा JSON फ़ाइलों या कस्टम यूटिलिटीज़ में बिखरे होने के बजाय केंद्रीकृत रहता है।
360
+
361
+ यह पूरी तरह से Next.js के लिए डिज़ाइन किया गया है, इसलिए आप कॉन्फ़िगरेशन डिबग करने में कम समय और शिपिंग में अधिक समय व्यतीत करते हैं।
362
+
363
+ यदि आपका लक्ष्य केवल अनुवाद करना नहीं बल्कि बिना किसी रुकावट के मल्टीलिंगुअल SEO को स्केल करना है, तो Intlayer आपको सबसे साफ़, सबसे भविष्य-सबूत सेटअप प्रदान करता है।