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: docs/docs/how-to/adding-common-features/creating-a-sitemap.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,10 @@ Think of it as a map for your website. It shows what all of the pages are on you
16
16
To generate an XML sitemap, you will use the [`gatsby-plugin-sitemap`](/plugins/gatsby-plugin-sitemap/) package.
17
17
18
18
Install the package by running the following command:
19
-
`npm install gatsby-plugin-sitemap`
19
+
20
+
```shell
21
+
npm install gatsby-plugin-sitemap
22
+
```
20
23
21
24
### How to configure
22
25
@@ -33,12 +36,8 @@ module.exports = {
33
36
34
37
**Note:** The siteUrl property must be defined and not left empty.
35
38
36
-
Next run a build (`npm run build`) since the sitemap generation will only happen for production builds. This is all that's required to get a working sitemap with Gatsby! By default, the generated sitemap path is /sitemap.xml and will include all of your site’s pages, but the plugin exposes options to configure this default functionality.
39
+
Next run a build (`npm run build`) since the sitemap generation will only happen for production builds. This is all that's required to get a working sitemap with Gatsby! By default, the generated sitemap path is `/sitemap-index.xml` and will hold an index of sitemap chunks, but the plugin exposes options to configure this default functionality.
37
40
38
41
### Additional modifications
39
42
40
43
Additional modification steps are available in the [`gatsby-plugin-sitemap` documentation](/plugins/gatsby-plugin-sitemap)
41
-
42
-
## More information
43
-
44
-
- Also check out a post on [gatsby-plugin-advanced-sitemap](/blog/2019-05-07-advanced-sitemap-plugin-for-seo/) from the Gatsby blog
// If you didn't use the resolveSiteUrl option this needs to be set
19
-
siteUrl:`https://www.example.com`,
20
-
},
21
-
plugins: [`gatsby-plugin-sitemap`]
15
+
```javascript:title=gatsby-config.js
16
+
module.exports= {
17
+
siteMetadata: {
18
+
// If you didn't use the resolveSiteUrl option this needs to be set
19
+
siteUrl:`https://www.example.com`,
20
+
},
21
+
plugins: [`gatsby-plugin-sitemap`]
22
+
}
22
23
```
23
24
24
-
Above is the minimal configuration required to have it work. By default, the
25
-
generated sitemap will include all of your site's pages, except the ones you exclude.
25
+
Above is the minimal configuration required to have it work. By default, the generated sitemap will include all of your site's pages, except the ones you exclude. It will generate a `sitemap-index.xml` file at the root of your site and for every 45000 URLs a new `sitemap-X.xml` file. The `sitemap-index.xml` file will point at the generated `.xml` files.
26
26
27
-
You then can point your service (e.g. Google Search Console) at `https://www.example.com/sitemap/sitemap-index.xml`.
27
+
You then can point your service (e.g. Google Search Console) at `https://www.example.com/sitemap-index.xml`.
28
28
29
29
## Recommended usage
30
30
@@ -49,7 +49,7 @@ You probably do not want to use the defaults in this plugin. Here's an example o
49
49
See the `changefreq` and `priority` fields? Those will be the same for every page, no matter how important or how often it gets updated. They will most likely be wrong. But wait, there's more, in their [docs](https://support.google.com/webmasters/answer/183668?hl=en) Google says:
50
50
51
51
> - Google ignores `<priority>` and `<changefreq>` values, so don't bother adding them.
52
-
> - Google reads the `<lastmod>` value, but if you misrepresent this value, we will stop reading it.
52
+
> - Google reads the `<lastmod>` value, but if you misrepresent this value, Google will stop reading it.
53
53
54
54
You really want to customize this plugin config to include an accurate `lastmod` date. Checkout the [example](#example) for an example of how to do this.
55
55
@@ -59,7 +59,7 @@ The [`default config`](https://github.com/gatsbyjs/gatsby/blob/master/packages/g
59
59
60
60
The options are as follows:
61
61
62
-
-`output` (string = `/sitemap`) Folder path where sitemaps are stored.
62
+
-`output` (string = `/`) Folder path where sitemaps are stored.
63
63
-`createLinkInHead` (boolean = true) Whether to populate the `<head>` of your site with a link to the sitemap.
64
64
-`entryLimit` (number = 45000) Number of entries per sitemap file. A sitemap index (as `sitemap-index.xml`) will always be created and multiple sitemaps are created for every `entryLimit` increment (e.g under 45000 entries only `sitemap-0.xml` will be created).
65
65
-`excludes` (string[] = []) An array of paths to exclude from the sitemap. You can use glob matching using [minimatch](https://github.com/isaacs/minimatch). While `excludes` is usually an array of strings it is possible to enter other data types into this array for custom filtering, but doing so will require customization of the [`filterPages`](#filterPages) function.
0 commit comments