Skip to content

Commit b645fdf

Browse files
authored
BREAKING(gatsby-plugin-sitemap): Change output default to / (#36812)
1 parent 7ab3c74 commit b645fdf

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

docs/docs/how-to/adding-common-features/creating-a-sitemap.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff 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
1616
To generate an XML sitemap, you will use the [`gatsby-plugin-sitemap`](/plugins/gatsby-plugin-sitemap/) package.
1717

1818
Install the package by running the following command:
19-
`npm install gatsby-plugin-sitemap`
19+
20+
```shell
21+
npm install gatsby-plugin-sitemap
22+
```
2023

2124
### How to configure
2225

@@ -33,12 +36,8 @@ module.exports = {
3336

3437
**Note:** The siteUrl property must be defined and not left empty.
3538

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

3841
### Additional modifications
3942

4043
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

docs/docs/how-to/plugins-and-themes/using-a-plugin-in-your-site.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = {
6767
{
6868
resolve: "gatsby-plugin-sitemap",
6969
options: {
70-
output: `/my-cool-sitemap.xml`,
70+
output: `/sitemap`,
7171
},
7272
},
7373
// highlight-end

packages/gatsby-plugin-sitemap/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ npm install gatsby-plugin-sitemap
1212

1313
## How to Use
1414

15-
```javascript
16-
// In your gatsby-config.js
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`]
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+
}
2223
```
2324

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

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

2929
## Recommended usage
3030

@@ -49,7 +49,7 @@ You probably do not want to use the defaults in this plugin. Here's an example o
4949
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:
5050

5151
> - 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.
5353
5454
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.
5555

@@ -59,7 +59,7 @@ The [`default config`](https://github.com/gatsbyjs/gatsby/blob/master/packages/g
5959

6060
The options are as follows:
6161

62-
- `output` (string = `/sitemap`) Folder path where sitemaps are stored.
62+
- `output` (string = `/`) Folder path where sitemaps are stored.
6363
- `createLinkInHead` (boolean = true) Whether to populate the `<head>` of your site with a link to the sitemap.
6464
- `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).
6565
- `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.

packages/gatsby-plugin-sitemap/src/__tests__/gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe(`gatsby-plugin-sitemap Node API`, () => {
5353
)
5454
const { destinationDir, sourceData } =
5555
sitemap.simpleSitemapAndIndex.mock.calls[0][0]
56-
expect(destinationDir).toEqual(path.join(`public`, `sitemap`))
56+
expect(destinationDir).toEqual(path.join(`public`, `/`))
5757
expect(sourceData).toMatchSnapshot()
5858
})
5959

packages/gatsby-plugin-sitemap/src/__tests__/options-validation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe(`pluginOptionsSchema`, () => {
3939
"entryLimit": 45000,
4040
"excludes": Array [],
4141
"filterPages": [Function],
42-
"output": "/sitemap",
42+
"output": "/",
4343
"query": "{ site { siteMetadata { siteUrl } } allSitePage { nodes { path } } }",
4444
"resolvePagePath": [Function],
4545
"resolvePages": [Function],

packages/gatsby-plugin-sitemap/src/options-validation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const pluginOptionsSchema = ({ Joi }) =>
1313
Joi.object({
1414
plugins: Joi.array().strip(),
1515
output: Joi.string()
16-
.default(`/sitemap`)
16+
.default(`/`)
1717
.description(`Folder path where sitemaps are stored in \`public\`.`),
1818
createLinkInHead: Joi.boolean()
1919
.default(true)

0 commit comments

Comments
 (0)