Google Search Console can't fetch sitemap on GitHub Pages
Tags: webdev, help, tutorial, github
Published: 2021-11-01 17:26:11

You decided to build your website and you did the decision to publish your tweaked website to [GitHub pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site). That's cool hosting for your static website to choose from. 

You do want to now see this page and other related pages indexed in Google as soon as possible. So you verified your page with Google Search Console with one of the options it offers. It is [uploading an HTML file](https://support.google.com/webmasters/answer/9008080?hl=en#html_verification&zippy=%2Chtml-file-upload) to your GitHub account right next to other website files or [adding a meta tag](https://support.google.com/webmasters/answer/9008080?hl=en#meta_tag_verification) to your site's homepage. 

That's great. But what if you would like to fetch the website's <code>sitemap XML</code> file and it won't work for you as good as you want this way?

##Google search console won't fetch your sitemap XML

There has been notified some indexation delays regards to Google index speed to process new pages on its own. To beat this issue, the best way is to submit <code>sitemap XML</code> into Google Search Console to let know google bot about your website's structure - pages your website has. But what if after adding <code>sitemap XML</code> file it shows up in the submitted sitemaps section "Couldn't fetch" info?

>There is no need to upload to GitHub pages file called <code>.nojekyll</code> as some advice has been found pointing out to this practice.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hcd4myw5rd6g2e6l78n.png)

##Create robots.txt file on Github Pages
To let know Google bot about your sitemap just simple create on a root level of GitHub pages file named <code>robots.txt</code> and write there this information. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rc1guf19a6xx04ux04ux.png)

First is about where your <code>sitemap XML</code> file is located and the rest of the information sayin' that your website si crawlable by any other crawlers (bots) in other words it's not blocking some specific bots from accessing content provided on a <code>sitemap XML</code> file as well.

```
Sitemap: https://your-website-url.github.io/sitemap.xml

User-agent: *
Disallow:
```
>After you created this <code>robots.txt</code> file you can add a new sitemap into Google Search Console again and after apx. 12 hours will be fetched for sure.

Another way around is submitting a <code>sitemap XML</code> file the way to enter the whole URL string of your website with <code>sitemap XML</code> file at the end of <code>https://www.google.com/ping?sitemap=</code> like this hereunter.  

```
https://www.google.com/ping?sitemap=<complete_url_of_sitemap>
```
For example:

```
https://www.google.com/ping?sitemap=https://your-website-url.github.io/sitemap.xml
```

Then enter this into your browser where you'll be notified about it as follows "Sitemap Notification Received". This will tell to Google bot to ping your <code>sitemap XML</code> URL and to process it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkhukq518kdy905aav52.png)

And that's it, whole magic is at the very end of this article. Next morning your <code>sitemap XML</code> file will be fetched as needed.

Thanks to [Richy Great](https://unsplash.com/@richygreat?utm_source=unsplash&utm_medium=referral&utm_content=CreditCopyTextGratitude) for the cover image from Unsplash.