Cloudflare Worker for Google Sites
Google Sites is great but some of its many limitations are a bit much. Here I demonstrate how we're using Cloudflare Workers (and Wrangler local development in Google Cloud Shell) to overcome some of these such as: duplicate home page, metadata modifications, and including scripts at the top-level rather than in IFRAME sandboxes
Key Points
Google Sites ...
... wraps all JavaScript (or any embedded HTML) in locked down sandbox <iframe>'s
... does not allow you to modify per-page metadata
... duplicates the home page!
Custom Domain hosting for Google Sites is done by ghs.googlehosted.com which uses SNI for HTTPS
Hence you cannot simply fetch() and set the Host header ... it will cause a TLS error
Wrangler is the CLI for developing Cloudflare Workers locally
Install wrangler for local development: npm install -g wrangler
Debug by first running npx wrangler dev at Terminal and then attaching in VS Code
Beware Content-Encoding "br" (Brotli)
StackOverflow: Brotli Decompress Webstreams (in Cloudflare Workers)
This doesn't happen on production because the worker is accessing ghs.googlehosted.com directly which does not do Brotli encoding
Markdown rendering referenced here is: https://marked.js.org/