Remove Google Sites™' white "Redirecting you to…" page with one Cloudflare Worker handler
Google Sites wraps links in a google.com redirect and navigates with a separate data-url attribute, so rewriting href alone does not remove the white page. Rewrite both, for your own domain only.
>_ INSIDE_THE_PAGE
Field | Detail |
|---|---|
Problem | Clicking a link to your own domain on a Google Sites page shows a white "Redirecting you to…" page first |
Difficulty | 2 of 5 |
Moving parts | 1 HTMLRewriter handler in the Worker in front of your Site |
Reversible | Yes: remove the handler |
Time and cost | About 15 minutes; Cloudflare free plan |
Skills | Part 0 done (a Worker in front of the Site), basic JavaScript |
Last verified | 2026-11-22 on www.eryc.my.id |
Is it possible?
Yes, for links to your own domain. Google Sites sends those links through google.com/url, which shows a white page before the real one loads. The Worker from part 0 already sees every Sites page, so it can put the real address back before the browser gets the HTML. Links to other sites keep Google's wrapper on purpose. The fix depends on Sites markup, which Google can change at any time.
This is part 1 of the series EmDash for Google Sites. It matters most once your blog is at /blog (part 2), because the Sites menu links to it as an outside page.
What is the big picture?
Google Sites wraps links in google.com/url?q=.. The edge Worker unwraps your own links before the browser sees them; external links stay wrapped.
The same flow as text:
- Google Sites wraps each link:
href="https://www.google.com/url?q=https://www.example.com/blog&sa=D...", the same value indata-url, anddata-navtype="2". - The edge Worker (part 0) fetches the page from Sites.
- HTMLRewriter looks at
hrefanddata-urlon every wrapped link. - If the
q=host isexample.comor*.example.com, it replaces the link with the real address. - Anything else is left as Google wrote it.
- The browser gets
href="https://www.example.com/blog"anddata-url="https://www.example.com/blog". - The click goes straight to
/blog, with no white page.
Where it fits with part 0: one more handler inside the edge Worker you already deployed. No new Worker, route or binding.
Which words do I need?
Word | Meaning here |
|---|---|
| Google's link wrapper; |
| The address a normal link points to |
| A Sites attribute; Sites' own script reads it on click, not |
| A Sites attribute; |
HTMLRewriter | Cloudflare's streaming HTML editor; it changes attributes as the page passes through |
Own domain | Your domain or a real subdomain of it; |
Step 1: See the wrapped link yourself
Where it fits: the GOOGLE SITES box.
Open any Sites page that links to /blog (or another address on your domain that Sites treats as outside), view the source, and find the link.
OBSERVED In the served HTML of my /about page, the menu link to https://www.eryc.my.id/blog had this href, in 3 anchors:
https://www.google.com/url?q=https%3A%2F%2Fwww.eryc.my.id%2Fblog&sa=D&sntz=1&usg=...A screen recording of the click (desktop Chrome, 1366×768) showed a white page at google.com reading "Redirecting you to https://www.eryc.my.id/blog" before the blog loaded.
Paste a link from your own source into the decoder to see what Sites did to it:
Step 2: Know why fixing only href fails
Where it fits: the HTMLREWRITER box, and why it has to touch two attributes.
Sites does not navigate with href. Pages inside the Site carry data-navtype="1" and a relative data-url such as /about. The Blog link carried data-navtype="2" and a data-url holding the same google.com address.
OBSERVED My first fix rewrote only href. The white page still appeared on click, because Sites' script reads data-url. Setting data-url to https://www.eryc.my.id/blog on the live homepage, by hand in DevTools, made the click go straight to /blog. That confirmed the cause.
Step 3: Rewrite both attributes, for your own domain only
Where it fits: inside the edge Worker's HTML response.
const OWN_DOMAIN = "example.com"; // your domain; real subdomains match too export function unwrapOwnLinks(response) { return new HTMLRewriter() .on('a[href^="https://www.google.com/url?q="], a[data-url^="https://www.google.com/url?q="]', { element(el) { for (const attr of ["href", "data-url"]) { const value = el.getAttribute(attr); if (!value) continue; try { const u = new URL(value); if (u.hostname !== "www.google.com" || u.pathname !== "/url") continue; const target = u.searchParams.get("q"); if (!target) continue; const host = new URL(target).hostname; if (host === OWN_DOMAIN || host.endsWith("." + OWN_DOMAIN)) el.setAttribute(attr, target); } catch (_) { // not a URL: leave it alone } } }, }) .transform(response);}Call it on HTML responses only, as the part 0 Worker already does:
const type = res.headers.get("content-type") || "";return type.includes("text/html") ? unwrapOwnLinks(res) : res;Check. MEASURED The repo's local test (2026-11-22, Miniflare, a stand-in Sites page): own-domain links unwrapped in both href and data-url, a GitHub link left wrapped, a look-alike badexample.com link left wrapped, 0 wrapped own-domain links left.
Step 4: Check every page
Where it fits: the CLEAN LINK box, on your live site.
From a terminal:
curl -s https://www.example.com/ | grep -o 'google.com/url?q=https%3A%2F%2Fwww.example.com[^"]*' | wc -lOr in the browser console on each page:
[...document.querySelectorAll('a')].filter(a => (a.getAttribute('href') || '').startsWith('https://www.google.com/url') || (a.getAttribute('data-url') || '').startsWith('https://www.google.com/url')).lengthThe terminal check prints 0 once the fix is live. The console check counts every wrapped link, so it prints 0 only on pages with no external links.
MEASURED On 2026-11-22, the served HTML of /, /about, /glossary, /case-studies/seo and /case-studies/edge-seo had 0 wrapped links to my own domain each. Clicking from the homepage to the blog showed no white page.
What went wrong?
- The first fix only rewrote
href. The white page stayed, because Sites navigates withdata-url. Step 2 shows how I found it. endsWith("example.com")was too loose. It also acceptsbadexample.com. Writing this post, I changed the repo and my production Worker to an exact match or a real subdomain, and added the look-alike case to the test. The loose version only ever unwrapped links that Sites itself put on my pages, so the risk was small.
Limits
- Depends on
data-urlanddata-navtype; Google can change them without notice. - Needs a Cloudflare Worker in front of the Sites domain (part 0).
- Only links to your own domain are unwrapped.
- NOT TESTED Safari, Firefox and Chrome on Android, and how long the google.com hop takes; I did not time it, so I give no number.
- On
/aboutthe only external link was a direct sites.google.com address, so I have no data on whether Google wraps every external link on other pages.
Files and reproduction
Repo: ErycTheGreat/emdash-for-google-sites, folder 01-redirect-fix: worker-snippet.js (the handler above) and CHECK.md. The same handler is already wired into 00-setup/sites-worker, with the local test (npm test). With an AI agent: "Use the emdash-for-google-sites skill, part 01".
Series: part 0, setup · part 2, the blog under /blog · part 1, this post · part 3, matching the look.
How this was made
Built and tested by Eryc Tri Juni S on his own site. The page counts come from his own fetches on 2026-11-22, the test from a local Miniflare run the same day. Drafted with AI assistance (Claude); every sentence was reviewed and every fact checked by the author.
About the author
Eryc Tri Juni S is an Edge SEO & GEO (Generative Engine Optimization) Specialist in Malang, Indonesia, an Electrical Engineer with 8 years in electronic product innovation, now at the intersection of Edge SEO, GEO, and AI retrieval infrastructure. About · GitHub
Changelog
- 2026-11-22: first version.
Google Sites is a trademark of Google LLC. This project is not affiliated with or endorsed by Google.
Related prompts
- 01
Why does Google Sites show a "Redirecting you to" page when I click a link?
- 02
How can I stop Google Sites from wrapping links in google.com/url?
- 03
Can a Cloudflare Worker change the HTML of a Google Sites page?