How to fix "Sitemap is not accessible" on Ahrefs in GatsbyJS


Update the gatsby-plugin-robots-txt plugin to reflect the correct sitemap.

The following article aims to resolve the issue that may arise in Ahref if you have not configured the robots.txt file of your GatsbyJS project to point to the correct URL.
For example, in our case, we had assumed that the sitemap.xml value was the same as the example on the gatsby-plugin-robots-txt example when in fact it was not.

To resolve this, do the steps below.
Step One: Find the correct Sitemap.xml URL

Determine the correct sitemap.xml URL.
Please note that we used the gatsby-plugin-sitemap to generate our sitemap.
Step Two: Update the Gatsby Config

In the gatsby-config.js, Update the gatsby-plugin-robots-txt sitemap option to point to the correct URL.
Step Three: Test

Build and deploy the Gatsby website and confirm that the sitemap is now accessible and that the crawl is successful.
Looking to learn more about ReactJS, GatsbyJS or SEO ?
Search our blog to find educational content on learning SEO as well as how to use ReactJS and GatsbyJS.