You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/integrations/sitemap/README.md
+182-1Lines changed: 182 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,35 @@ export default {
64
64
}
65
65
```
66
66
67
-
Now, [build your site for production](https://docs.astro.build/en/reference/cli-reference/#astro-build) via the `astro build` command. You should find your sitemap under `dist/sitemap.xml`!
67
+
Now, [build your site for production](https://docs.astro.build/en/reference/cli-reference/#astro-build) via the `astro build` command. You should find your _sitemap_ under `dist/sitemap-index.xml` and `dist/sitemap-0.xml`!
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
70
98
@@ -111,5 +139,158 @@ export default {
111
139
}
112
140
```
113
141
142
+
### entryLimit
143
+
144
+
Non-negative `Number` of entries per sitemap file. Default value is 45000. A sitemap index and multiple sitemaps are created if you have more entries. See explanation on [Google](https://developers.google.com/search/docs/advanced/sitemaps/large-sitemaps).
145
+
146
+
__astro.config.mjs__
147
+
148
+
```js
149
+
importsitemapfrom'@astrojs/sitemap';
150
+
151
+
exportdefault {
152
+
site:'https://stargazers.club',
153
+
integrations: [
154
+
sitemap({
155
+
entryLimit:10000,
156
+
}),
157
+
],
158
+
}
159
+
```
160
+
161
+
### changefreq, lastmod, priority
162
+
163
+
`changefreq` - How frequently the page is likely to change. Available values: `always`\|`hourly`\|`daily`\|`weekly`\|`monthly`\|`yearly`\|`never`.
164
+
165
+
`priority` - The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.
166
+
167
+
`lastmod` - The date of page last modification.
168
+
169
+
`changefreq` and `priority` are ignored by Google.
170
+
171
+
See detailed explanation of sitemap specific options on [sitemap.org](https://www.sitemaps.org/protocol.html).
172
+
173
+
174
+
:exclamation: This integration uses 'astro:build:done' hook. The hook exposes generated page paths only. So with present version of Astro the integration has no abilities to analyze a page source, frontmatter etc. The integration can add `changefreq`, `lastmod` and `priority` attributes only in a batch or nothing.
175
+
176
+
__astro.config.mjs__
177
+
178
+
```js
179
+
importsitemapfrom'@astrojs/sitemap';
180
+
181
+
exportdefault {
182
+
site:'https://stargazers.club',
183
+
integrations: [
184
+
sitemap({
185
+
changefreq:'weekly',
186
+
priority:0.7,
187
+
lastmod:newDate('2022-02-24'),
188
+
}),
189
+
],
190
+
}
191
+
```
192
+
193
+
### serialize
194
+
195
+
Async or sync function called for each sitemap entry just before writing to a disk.
196
+
197
+
It receives as parameter `SitemapItem` object which consists of `url` (required, absolute page URL) and optional `changefreq`, `lastmod`, `priority` and `links` properties.
198
+
199
+
Optional `links` property contains a `LinkItem` list of alternate pages including a parent page.
200
+
`LinkItem` type has two required fields: `url` (the fully-qualified URL for the version of this page for the specified language) and `hreflang` (a supported language code targeted by this version of the page).
201
+
202
+
`serialize` function should return `SitemapItem`, touched or not.
203
+
204
+
The example below shows the ability to add the sitemap specific properties individually.
205
+
206
+
__astro.config.mjs__
207
+
208
+
```js
209
+
importsitemapfrom'@astrojs/sitemap';
210
+
211
+
exportdefault {
212
+
site:'https://stargazers.club',
213
+
integrations: [
214
+
sitemap({
215
+
serialize(item) {
216
+
if (/your-special-page/.test(item.url)) {
217
+
item.changefreq='daily';
218
+
item.lastmod=newDate();
219
+
item.priority=0.9;
220
+
}
221
+
return item;
222
+
},
223
+
}),
224
+
],
225
+
}
226
+
```
227
+
228
+
### i18n
229
+
230
+
To localize a sitemap you should supply the integration config with the `i18n` option. The integration will check generated page paths on presence of locale keys in paths.
231
+
232
+
`i18n` object has two required properties:
233
+
234
+
-`defaultLocale`: `String`. Its value must exist as one of `locales` keys.
235
+
-`locales`: `Record<String, String>`, key/value - pairs. The key is used to look for a locale part in a page path. The value is a language attribute, only English alphabet and hyphen allowed. See more about language attribute on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang).
236
+
237
+
238
+
Read more about localization on Google in [Advanced SEO](https://developers.google.com/search/docs/advanced/crawling/localized-versions#all-method-guidelines).
239
+
240
+
__astro.config.mjs__
241
+
242
+
```js
243
+
importsitemapfrom'@astrojs/sitemap';
244
+
245
+
exportdefault {
246
+
site:'https://stargazers.club',
247
+
integrations: [
248
+
sitemap({
249
+
i18n: {
250
+
defaultLocale:'en', // All urls that don't contain `es` or `fr` after `https://stargazers.club/` will be treated as default locale, i.e. `en`
251
+
locales: {
252
+
en:'en-US', // The `defaultLocale` value must present in `locales` keys
0 commit comments