Open cameronmccord2 opened 2 years ago
Thanks for the detailed report! This issue has come up a number of times, but usually users are able to resolve it after realizing they didn't follow all steps, like updating the robots.txt
file. I'd like to have another user with the same issue confirm your fix before I update the documentation. I'll leave this issue open for a while to see if we get any +1s.
We found a workaround that works perfectly! (using AWS S3 to storage our sitemap files)
#config/sitemap.rb
SitemapGenerator::Sitemap.create_index = true
SitemapGenerator::Sitemap.default_host = 'https://yourdomain.com'
SitemapGenerator::Sitemap.sitemaps_host = 'https://yourdomain.com'
#config/routes.rb
base_sitemap_url = "https://#{ENV['AWS_ASSETS_BUCKET']}.s3.amazonaws.com"
get 'sitemap.xml.gz', to: redirect("#{base_sitemap_url}/sitemap.xml.gz")
get 'sitemap:number.xml.gz',
to: redirect("#{base_sitemap_url}/sitemap%{number}.xml.gz")
Just make sure your sitemap index is 100% correct!
We run Rails(6.0.3.7) on Heroku and host our sitemaps on our S3 bucket. The readme worked great except that Google wouldn't accept our sitemaps because they were a different host than our website(OURBUCKET.s3.amazonaws.com vs www.shout.app). Our S3 bucket was fully verified in Google with an html verification file placed in our bucket's /sitemaps/ folder.
What fixed it was to set our sitemaps_host to the same as default_host and add redirects to our routes file for the sitemaps as seen below. This way all sitemap urls that Google sees are to our website and not to an S3 bucket.
We also changed our robots.txt to use our website's redirect instead of an S3 url
The readme section https://github.com/kjvarga/sitemap_generator#an-example-of-using-an-adapter didn't work because it had us using the S3 urls and not our site's urls. If you'd like I can submit a PR that updates that section of the readme or adds another section under that section detailing this setup