How to Correctly Submit Your Hugo Website Sitemap to Google Seach Console
I currently host my hugo website on netlify and have noticed on occasion that when I initially submitted my sitemap.xml
file to google search console but I kept recieveing a not found
response from Google despite the url being “correct”.
It was a little confusing 1 - I could access my sitemap using the url I submitted - https://blog.luke-morgan.com/sitemap.xml and 2 - Google Search console wasn’t telling me it failed due to a redirect.
What made it harder to find the real problem, was that if I did a URL inspection on that Sitemap URL - I’d get a positive looking report the the URL existed but wasn’t yet indexed.
And If I then live tested that URL to see how Google would respond.
So whats the actual problem? ( and the fix! )
Whats happening here is partly due to how Hugo builds our projects - using path breakdown and also when we access live urls on our site, netlify handles alot of the redirects for us.
The url you’ll want to submit to google is https://yourdomain.com/sitemap.xml/
. Take note of the trailing slash
on that exmaple - it’s really important!
Going forward - any URLs you Submit to Google Search Console for your Hugo website, you can be sure you’ll need the trailing slash on the end of the URL. This is purely down to how Hugo builds your project. Everything is a directory and every directory will have some sort of index file.
Read about path breakdown in Hugo
Once I submitted a sitemap url with the trailing slash
Google search console had no problem finding the sitemap. Happy indexing!