Albert Hoffman
Albert Hoffman

Reputation: 39

How to change the url of gatsby sitemap?

I used https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/ to create the sitemap for my website.

Currently, the sitemap is listed at https://www.myWebsite.com/sitemap/sitemap-0.xml, but I want it to be located at https://www.myWebsite.com/sitemap.xml

How can I change the sitemap's location? Sorry if this is obvious

Upvotes: 1

Views: 1621

Answers (2)

SMantoc
SMantoc

Reputation: 1

Another solution is to use the same gatsby-plugin-sitemap plugin and then add: gatsby-plugin-robots-txt plugin and point to the file name in the gatsby-config Something as bellow: { resolve: 'gatsby-plugin-robots-txt', options: { host: SiteConfig.url, sitemap: ${SiteConfig.url}/sitemap.xml, HERE PLACE sitemap-0.xml policy: [{ userAgent: '*', allow: '/' }] } }, After doing that, look for set up on webpage/robots.txt to see where is the point

Upvotes: 0

Ferran Buireu
Ferran Buireu

Reputation: 29315

You can't automatically since there's no option nor configuration to do so. Your only change is using any small Node script that changes the filename or doing it manually.

However, there's no SEO problem at all having a sitemap-0.xml as long as you point your Google's Search Console to that file.

Another solution is using gatsby-plugin-advanced-sitemap which by default outputs a file named sitemal.xml as you can see in their example: https://gatsby.ghost.org/sitemap.xml. This plugin is based on the one you are using so it should be quite straightforward swapping between them.

Upvotes: 1

Related Questions