Duplicate without user-selected canonical

Google Sites is great but your root page "/" is duplicated with what you name it. Thus if you name it "Home" then both / and /home contain the same content and then Google Search Console complains:

I managed to work around this issue by using Cloudflare Workers. If your domain isn't hosted there then an alternative is to specify a sitemap since Google Sites doesn't let you add headers (e.g. specify canonical pages).

/**

* Learn more at https://developers.cloudflare.com/workers/

*/

export default {

 async fetch(request) {

   const url = new URL(request.url)


   // prevent index issue: Duplicate without user-selected canonical

   if (url.pathname == "/home") {

     url.pathname = "/"

     return Response.redirect(url.toString(), 302) // found / temporary

   }


   return fetch(url, request)

 },

}

This works fine but I was also hoping that I could bypass having to publish to a custom domain altogether and just fetch directly against ghs.googlehosted.com. That doesn't work, however, because it (rightly) uses SNI for HTTPS which causes the fetch to barf if you try changing the Host simply through headers. Doh!

Update: Success!