Skip to content

Commit 12fc046

Browse files
gouravkhungeryanthomasdevematipicosarah11918ArmandPhilippot
authored
docs(en/sitemap.mdx): describe customSitemaps (#11563)
Co-authored-by: Yan <[email protected]> Co-authored-by: Emanuele Stoppa <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: ArmandPhilippot <[email protected]> Co-authored-by: bjohansebas <[email protected]>
1 parent 7a2ac9b commit 12fc046

File tree

1 file changed

+67
-37
lines changed
  • src/content/docs/en/guides/integrations-guide

1 file changed

+67
-37
lines changed

src/content/docs/en/guides/integrations-guide/sitemap.mdx

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ category: other
99
i18nReady: true
1010
---
1111
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro';
12+
import Since from '~/components/Since.astro';
1213

1314
This **[Astro integration][astro-integration]** generates a sitemap based on your pages when you build your Astro project.
1415

@@ -93,7 +94,7 @@ import { defineConfig } from 'astro/config';
9394
import sitemap from '@astrojs/sitemap';
9495

9596
export default defineConfig({
96-
site: 'https://stargazers.club',
97+
site: 'https://example.com',
9798
integrations: [sitemap()],
9899
// ...
99100
});
@@ -112,7 +113,7 @@ For extremely large sites, there may also be additional numbered files like `sit
112113
<?xml version="1.0" encoding="UTF-8"?>
113114
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
114115
<sitemap>
115-
<loc>https://stargazers.club/sitemap-0.xml</loc>
116+
<loc>https://example.com/sitemap-0.xml</loc>
116117
</sitemap>
117118
</sitemapindex>
118119
```
@@ -121,10 +122,10 @@ For extremely large sites, there may also be additional numbered files like `sit
121122
<?xml version="1.0" encoding="UTF-8"?>
122123
<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">
123124
<url>
124-
<loc>https://stargazers.club/</loc>
125+
<loc>https://example.com/</loc>
125126
</url>
126127
<url>
127-
<loc>https://stargazers.club/second-page/</loc>
128+
<loc>https://example.com/second-page/</loc>
128129
</url>
129130
</urlset>
130131
```
@@ -201,10 +202,10 @@ import { defineConfig } from 'astro/config';
201202
import sitemap from '@astrojs/sitemap';
202203

203204
export default defineConfig({
204-
site: 'https://stargazers.club',
205+
site: 'https://example.com',
205206
integrations: [
206207
sitemap({
207-
filter: (page) => page !== 'https://stargazers.club/secret-vip-lounge/',
208+
filter: (page) => page !== 'https://example.com/secret-vip-lounge/',
208209
}),
209210
],
210211
});
@@ -219,32 +220,61 @@ import { defineConfig } from 'astro/config';
219220
import sitemap from '@astrojs/sitemap';
220221

221222
export default defineConfig({
222-
site: 'https://stargazers.club',
223+
site: 'https://example.com',
223224
integrations: [
224225
sitemap({
225226
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/',
230231
}),
231232
],
232233
});
233234
```
234235

235236
### customPages
236237

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.
238268

239269
```js title="astro.config.mjs" ins={8}
240270
import { defineConfig } from 'astro/config';
241271
import sitemap from '@astrojs/sitemap';
242272

243273
export default defineConfig({
244-
site: 'https://stargazers.club',
274+
site: 'https://example.com',
245275
integrations: [
246276
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'],
248278
}),
249279
],
250280
});
@@ -259,7 +289,7 @@ import { defineConfig } from 'astro/config';
259289
import sitemap from '@astrojs/sitemap';
260290

261291
export default defineConfig({
262-
site: 'https://stargazers.club',
292+
site: 'https://example.com',
263293
integrations: [
264294
sitemap({
265295
entryLimit: 10000,
@@ -283,7 +313,7 @@ import { defineConfig } from 'astro/config';
283313
import sitemap from '@astrojs/sitemap';
284314

285315
export default defineConfig({
286-
site: 'https://stargazers.club',
316+
site: 'https://example.com',
287317
integrations: [
288318
sitemap({
289319
changefreq: 'weekly',
@@ -319,7 +349,7 @@ import { defineConfig } from 'astro/config';
319349
import sitemap from '@astrojs/sitemap';
320350

321351
export default defineConfig({
322-
site: 'https://stargazers.club',
352+
site: 'https://example.com',
323353
integrations: [
324354
sitemap({
325355
serialize(item) {
@@ -356,11 +386,11 @@ import { defineConfig } from 'astro/config';
356386
import sitemap from '@astrojs/sitemap';
357387

358388
export default defineConfig({
359-
site: 'https://stargazers.club',
389+
site: 'https://example.com',
360390
integrations: [
361391
sitemap({
362392
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`
364394
locales: {
365395
en: 'en-US', // The `defaultLocale` value must present in `locales` keys
366396
es: 'es-ES',
@@ -377,28 +407,28 @@ The resulting sitemap looks like this:
377407
```xml title="sitemap-0.xml"
378408
...
379409
<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/"/>
384414
</url>
385415
<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/"/>
390420
</url>
391421
<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/"/>
396426
</url>
397427
<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/"/>
402432
</url>
403433
...
404434
```
@@ -434,7 +464,7 @@ import { defineConfig } from 'astro/config';
434464
import sitemap from '@astrojs/sitemap';
435465

436466
export default defineConfig({
437-
site: 'https://stargazers.club',
467+
site: 'https://example.com',
438468
integrations: [
439469
sitemap({
440470
filenameBase: 'astronomy-sitemap'
@@ -443,7 +473,7 @@ export default defineConfig({
443473
});
444474
```
445475

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`.
447477

448478
## Examples
449479

0 commit comments

Comments
 (0)