@@ -9,6 +9,7 @@ category: other
9
9
i18nReady : true
10
10
---
11
11
import PackageManagerTabs from ' ~/components/tabs/PackageManagerTabs.astro' ;
12
+ import Since from ' ~/components/Since.astro' ;
12
13
13
14
This ** [ Astro integration] [ astro-integration ] ** generates a sitemap based on your pages when you build your Astro project.
14
15
@@ -93,7 +94,7 @@ import { defineConfig } from 'astro/config';
93
94
import sitemap from ' @astrojs/sitemap' ;
94
95
95
96
export default defineConfig ({
96
- site: ' https://stargazers.club ' ,
97
+ site: ' https://example.com ' ,
97
98
integrations: [sitemap ()],
98
99
// ...
99
100
});
@@ -112,7 +113,7 @@ For extremely large sites, there may also be additional numbered files like `sit
112
113
<?xml version =" 1.0" encoding =" UTF-8" ?>
113
114
<sitemapindex xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" >
114
115
<sitemap >
115
- <loc >https://stargazers.club /sitemap-0.xml</loc >
116
+ <loc >https://example.com /sitemap-0.xml</loc >
116
117
</sitemap >
117
118
</sitemapindex >
118
119
```
@@ -121,10 +122,10 @@ For extremely large sites, there may also be additional numbered files like `sit
121
122
<?xml version =" 1.0" encoding =" UTF-8" ?>
122
123
<urlset xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" xmlns : news =" http://www.google.com/schemas/sitemap-news/0.9" xmlns : xhtml =" http://www.w3.org/1999/xhtml" xmlns : image =" http://www.google.com/schemas/sitemap-image/1.1" xmlns : video =" http://www.google.com/schemas/sitemap-video/1.1" >
123
124
<url >
124
- <loc >https://stargazers.club /</loc >
125
+ <loc >https://example.com /</loc >
125
126
</url >
126
127
<url >
127
- <loc >https://stargazers.club /second-page/</loc >
128
+ <loc >https://example.com /second-page/</loc >
128
129
</url >
129
130
</urlset >
130
131
```
@@ -201,10 +202,10 @@ import { defineConfig } from 'astro/config';
201
202
import sitemap from ' @astrojs/sitemap' ;
202
203
203
204
export default defineConfig ({
204
- site: ' https://stargazers.club ' ,
205
+ site: ' https://example.com ' ,
205
206
integrations: [
206
207
sitemap ({
207
- filter : (page ) => page !== ' https://stargazers.club /secret-vip-lounge/' ,
208
+ filter : (page ) => page !== ' https://example.com /secret-vip-lounge/' ,
208
209
}),
209
210
],
210
211
});
@@ -219,32 +220,61 @@ import { defineConfig } from 'astro/config';
219
220
import sitemap from ' @astrojs/sitemap' ;
220
221
221
222
export default defineConfig ({
222
- site: ' https://stargazers.club ' ,
223
+ site: ' https://example.com ' ,
223
224
integrations: [
224
225
sitemap ({
225
226
filter : (page ) =>
226
- page !== ' https://stargazers.club /secret-vip-lounge-1/' &&
227
- page !== ' https://stargazers.club /secret-vip-lounge-2/' &&
228
- page !== ' https://stargazers.club /secret-vip-lounge-3/' &&
229
- page !== ' https://stargazers.club /secret-vip-lounge-4/' ,
227
+ page !== ' https://example.com /secret-vip-lounge-1/' &&
228
+ page !== ' https://example.com /secret-vip-lounge-2/' &&
229
+ page !== ' https://example.com /secret-vip-lounge-3/' &&
230
+ page !== ' https://example.com /secret-vip-lounge-4/' ,
230
231
}),
231
232
],
232
233
});
233
234
```
234
235
235
236
### customPages
236
237
237
- In some cases, a page might be part of your deployed site but not part of your Astro project. If you'd like to include a page in your sitemap that * isn't* created by Astro, you can use this option.
238
+ An array of externally-generated pages to be included in the generated sitemap file.
239
+
240
+ Use this option to include pages in your sitemap that are a part of your deployed site but are not created by Astro.
241
+
242
+ ``` js title="astro.config.mjs" ins={8}
243
+ import { defineConfig } from ' astro/config' ;
244
+ import sitemap from ' @astrojs/sitemap' ;
245
+
246
+ export default defineConfig ({
247
+ site: ' https://example.com' ,
248
+ integrations: [
249
+ sitemap ({
250
+ customPages: [' https://example.com/external-page1' , ' https://example.com/external-page2' ],
251
+ }),
252
+ ],
253
+ });
254
+ ```
255
+
256
+ ### customSitemaps
257
+
258
+ <p >
259
+
260
+ ** Type:** ` string[] ` <br />
261
+ ** Default:** ` [] ` <br />
262
+ <Since v = " 3.5.0" pkg = " @astrojs/sitemap" />
263
+ </p >
264
+
265
+ An array of externally-generated sitemaps to be included in the ` sitemap-index.xml ` file along with the generated sitemap entries.
266
+
267
+ Use this option to include external sitemaps in the ` sitemap-index.xml ` file created by Astro for sections of your deployed site that have their own sitemaps not created by Astro. This is helpful when you host multiple services under the same domain.
238
268
239
269
``` js title="astro.config.mjs" ins={8}
240
270
import { defineConfig } from ' astro/config' ;
241
271
import sitemap from ' @astrojs/sitemap' ;
242
272
243
273
export default defineConfig ({
244
- site: ' https://stargazers.club ' ,
274
+ site: ' https://example.com ' ,
245
275
integrations: [
246
276
sitemap ({
247
- customPages : [' https://stargazers.club/external-page ' , ' https://stargazers.club/external-page2 ' ],
277
+ customSitemaps : [' https://example.com/blog/sitemap.xml ' , ' https://example.com/shop/sitemap.xml ' ],
248
278
}),
249
279
],
250
280
});
@@ -259,7 +289,7 @@ import { defineConfig } from 'astro/config';
259
289
import sitemap from ' @astrojs/sitemap' ;
260
290
261
291
export default defineConfig ({
262
- site: ' https://stargazers.club ' ,
292
+ site: ' https://example.com ' ,
263
293
integrations: [
264
294
sitemap ({
265
295
entryLimit: 10000 ,
@@ -283,7 +313,7 @@ import { defineConfig } from 'astro/config';
283
313
import sitemap from ' @astrojs/sitemap' ;
284
314
285
315
export default defineConfig ({
286
- site: ' https://stargazers.club ' ,
316
+ site: ' https://example.com ' ,
287
317
integrations: [
288
318
sitemap ({
289
319
changefreq: ' weekly' ,
@@ -319,7 +349,7 @@ import { defineConfig } from 'astro/config';
319
349
import sitemap from ' @astrojs/sitemap' ;
320
350
321
351
export default defineConfig ({
322
- site: ' https://stargazers.club ' ,
352
+ site: ' https://example.com ' ,
323
353
integrations: [
324
354
sitemap ({
325
355
serialize (item ) {
@@ -356,11 +386,11 @@ import { defineConfig } from 'astro/config';
356
386
import sitemap from ' @astrojs/sitemap' ;
357
387
358
388
export default defineConfig ({
359
- site: ' https://stargazers.club ' ,
389
+ site: ' https://example.com ' ,
360
390
integrations: [
361
391
sitemap ({
362
392
i18n: {
363
- defaultLocale: ' en' , // All urls that don't contain `es` or `fr` after `https://stargazers.club /` will be treated as default locale, i.e. `en`
393
+ defaultLocale: ' en' , // All urls that don't contain `es` or `fr` after `https://example.com /` will be treated as default locale, i.e. `en`
364
394
locales: {
365
395
en: ' en-US' , // The `defaultLocale` value must present in `locales` keys
366
396
es: ' es-ES' ,
@@ -377,28 +407,28 @@ The resulting sitemap looks like this:
377
407
``` xml title="sitemap-0.xml"
378
408
...
379
409
<url >
380
- <loc >https://stargazers.club /</loc >
381
- <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://stargazers.club /" />
382
- <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://stargazers.club /es/" />
383
- <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://stargazers.club /fr/" />
410
+ <loc >https://example.com /</loc >
411
+ <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://example.com /" />
412
+ <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://example.com /es/" />
413
+ <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://example.com /fr/" />
384
414
</url >
385
415
<url >
386
- <loc >https://stargazers.club /es/</loc >
387
- <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://stargazers.club /" />
388
- <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://stargazers.club /es/" />
389
- <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://stargazers.club /fr/" />
416
+ <loc >https://example.com /es/</loc >
417
+ <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://example.com /" />
418
+ <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://example.com /es/" />
419
+ <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://example.com /fr/" />
390
420
</url >
391
421
<url >
392
- <loc >https://stargazers.club /fr/</loc >
393
- <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://stargazers.club /" />
394
- <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://stargazers.club /es/" />
395
- <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://stargazers.club /fr/" />
422
+ <loc >https://example.com /fr/</loc >
423
+ <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://example.com /" />
424
+ <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://example.com /es/" />
425
+ <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://example.com /fr/" />
396
426
</url >
397
427
<url >
398
- <loc >https://stargazers.club /es/second-page/</loc >
399
- <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://stargazers.club /es/second-page/" />
400
- <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://stargazers.club /fr/second-page/" />
401
- <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://stargazers.club /second-page/" />
428
+ <loc >https://example.com /es/second-page/</loc >
429
+ <xhtml : link rel =" alternate" hreflang =" es-ES" href =" https://example.com /es/second-page/" />
430
+ <xhtml : link rel =" alternate" hreflang =" fr-CA" href =" https://example.com /fr/second-page/" />
431
+ <xhtml : link rel =" alternate" hreflang =" en-US" href =" https://example.com /second-page/" />
402
432
</url >
403
433
...
404
434
```
@@ -434,7 +464,7 @@ import { defineConfig } from 'astro/config';
434
464
import sitemap from ' @astrojs/sitemap' ;
435
465
436
466
export default defineConfig ({
437
- site: ' https://stargazers.club ' ,
467
+ site: ' https://example.com ' ,
438
468
integrations: [
439
469
sitemap ({
440
470
filenameBase: ' astronomy-sitemap'
@@ -443,7 +473,7 @@ export default defineConfig({
443
473
});
444
474
```
445
475
446
- The given configuration will generate sitemap files at ` https://stargazers.club /astronomy-sitemap-0.xml ` and ` https://stargazers.club /astronomy-sitemap-index.xml ` .
476
+ The given configuration will generate sitemap files at ` https://example.com /astronomy-sitemap-0.xml ` and ` https://example.com /astronomy-sitemap-index.xml ` .
447
477
448
478
## Examples
449
479
0 commit comments