Poradnik: JavaScript Redirects
co a JavaScript redirect jest, how Google's render pipeline treats it differently z a serwer-side 301, gdy it's an acceptable ostatni resort, i how to implement i detect one — plus gdzie meta refresh i the History API fit.
Języki
1 sygnał dowodowy na tej stronie
- Powiązane działające narzędzierobots.txt Tester
A JavaScript redirect wysyła użytkownicy i crawlers to a new URL z client-side code (window.location.zastępować() lub .href). It's the least niezawodny redirect type ponieważ Google tylko sees it po renderowanie — który może być delayed, lub fail entirely, z no fixed timeline either way. Google's official order of preference jest serwer-side (301/302/307/308) → meta refresh → JavaScript, i jego docs say plainly: tylko używać JS redirects if you może't robić the other two. Once Google successfully interprets one, the target becomes a canonicalization signal — ale że's nie a proven guarantee of identical PageRank lub ranking outcomes to a 301, so treat it as a ostatni resort zamiast a like-dla-like swap. używać them on constrained platformy z no serwer access, dla SPA błąd strony że point to a rzeczywisty 404, i little else. If you musi używać one, używać window.location.zastępować() in the <head>, drop the źródło URL z twój mapa witryny, i point linki wewnętrzne at the final destination. Meta refresh jest a oddzielny HTML-level redirect, i history.pushState()/replaceState() aren't redirects at wszystkie.
TL;DR — A JavaScript redirect używa code in the strona to wysyłać you to a różny URL po the strona loads. It działa dla people, ale wyszukiwarki handle it mniej reliably than a “real” serwer redirect (a 301). If you może ustawić up a 301 instead, robić że. Save JavaScript redirects dla gdy you mieć no other option.
co a JavaScript redirect jest
A JavaScript redirect changes navigation przez script execution zamiast an HTTP 3xx odpowiedź. Evidence for this claim Primary standard or official documentation supporting the adjacent article claim. Scope: Protocol semantics and Search behavior are kept separate; no indexing, ranking, or migration-timing guarantee is inferred. Confidence: high · Verified: Google: JavaScript redirects Google może proces JavaScript redirects ale recommends serwer-side redirects gdy possible. Evidence for this claim Primary standard or official documentation supporting the adjacent article claim. Scope: Protocol semantics and Search behavior are kept separate; no indexing, ranking, or migration-timing guarantee is inferred. Confidence: high · Verified: Google: Redirects and Search
There są two broad ways to wysyłać someone z one URL to another.
The pierwszy jest a serwer-side redirect. przed the strona even loads, the serwer says “that page moved — go here instead” używając a kod stanu like 301 (permanent) lub 302 (temporary). The przeglądarka i the wyszukiwarka oba get że message immediately.
The second jest a JavaScript redirect. The strona loads normally, i then a bit of code runs in the przeglądarka i wysyła you somewhere else. Something like:
<script>
window.location.replace("https://example.com/new-page/");
</script>dla a person clicking around, the two feel almost the same. dla a wyszukiwarka, they’re bardzo różny — i że difference jest the whole powód ten strona exists.
Why wyszukiwarki treat them differently
Google reads twój strona in stages. pierwszy it crawls (downloads the raw HTML). Later it renders the strona — actually running the JavaScript, the way a przeglądarka by. A serwer-side 301 jest visible in że pierwszy krok. A JavaScript redirect isn’t visible until the renderowanie krok, który może come much later — lub, czasami, nie at wszystkie.
Google says it directly: “Only use JavaScript redirects if you can’t do server-side or meta refresh redirects.” (Google Search Central)
So a JavaScript redirect isn’t bad — it’s just mniej niezawodny. Google będzie zwykle get there eventually, ale a rzeczywisty 301 jest faster i więcej certain.
The prosty reguła
- może you ustawić a 301 (lub 302)? robić że. It’s the gold standard.
- może’t touch the serwer, ale może edit the HTML
<head>? A 0-second meta refresh jest the następny-best option. - Neither? Then a JavaScript redirect jest a fine ostatni resort.
A couple of things people get błędny:
- A meta refresh jest nie a JavaScript redirect. It’s a
<meta>znacznik in twój HTML, i Google handles it earlier i więcej reliably than JS. history.pushState()jest nie a redirect. It just changes co’s in the address bar — it doesn’t wysyłać anyone anywhere, i wyszukiwarki don’t follow it.
Want the render-pipeline timing, the implementacja details, i how to find JS redirects in a crawl? Switch to the Advanced tab.
TL;DR — A JavaScript redirect jest a client-side redirect (
window.location.replace(),.href,.assign()) że Google tylko procesy po renderowanie — phase three of crawl → render → index. A serwer-side 301 jest seen at crawl time; a JS redirect waits on the render queue, i Google gives no fixed timeline dla że wait — it może być quick lub it może take a long podczas gdy, i renderowanie może fail outright. Google’s udokumentowany preference order jest serwer-side → meta refresh → JavaScript, i the docs say to używać JS redirects tylko gdy you może’t robić the other two. Once Google successfully interprets one, the target becomes a permanent canonicalization signal — even Google używany them on ich own blog gdy nothing else worked — ale że’s nie udokumentowany proof of identical PageRank lub ranking outcomes to a 301, so they’re a ostatni resort, nie a spam signal. The legitimate używa są constrained platformy z no serwer config i SPA błąd strony że point at a rzeczywisty 404. Implement zwindow.location.replace()in the<head>, drop the źródło z twój mapa witryny, repoint linki wewnętrzne, i confirm Googlebot może fetch the JS. Meta refresh jest HTML-level (0s = permanent, dowolny opóźnienie = temporary), ihistory.pushState()/replaceState()aren’t redirects at wszystkie.
co counts as a JavaScript redirect
Script navigation depends on renderowanie i execution, so it jest nie protokół-equivalent to an HTTP redirect. Evidence for this claim Primary standard or official documentation supporting the adjacent article claim. Scope: Protocol semantics and Search behavior are kept separate; no indexing, ranking, or migration-timing guarantee is inferred. Confidence: high · Verified: Google: JavaScript redirects Processing jest possible, nie an dokładny-timing lub indeksowanie guarantee. Evidence for this claim Primary standard or official documentation supporting the adjacent article claim. Scope: Protocol semantics and Search behavior are kept separate; no indexing, ranking, or migration-timing guarantee is inferred. Confidence: high · Verified: Google: Redirects and Search
A JavaScript redirect navigates the przeglądarka to a new URL z client-side code. The common metody, i how they differ:
window.location.replace("url")— navigates i removes the original URL z session history. ten jest the one to używać: the back button skips the redirect źródło zamiast bouncing the użytkownik straight back.window.location.href = "url"— navigates ale zachowuje the original in history, so the back button zwroty to the redirecting strona (i może create a loop).document.location.hrefiwindow.location.assign("url")behave the same way.history.pushState()/history.replaceState()— nie redirects. They rewrite the address bar bez dowolny navigation lub HTTP signal, so crawlers don’t treat them as redirects. SPAs używać them dla in-app URL changes; they need rzeczywisty<a href>links (lub rzeczywisty navigations) to być crawlable.
The dividing wiersz że matters: .replace(), .href, i .assign() wszystkie trigger
a rzeczywisty document navigation (the difference między them jest tylko co happens to
session history), podczas gdy pushState()/replaceState() nigdy navigate at wszystkie —
they touch history state i the address bar i nothing else. None of the four jest
an HTTP 301; “redirect” here jest shorthand dla client-side navigation, nie a status
code.
Meta refresh (<meta http-equiv="refresh" content="0;url=...">) jest często
lumped in z JS redirects, ale it’s an HTML directive parsed przed JavaScript
runs — a oddzielny, więcej niezawodny kategoria, covered below.
How Google procesy a JavaScript redirect
ten jest the crux. Google’s pipeline runs in stages, i a JS redirect i a serwer-side redirect get caught at różny ones:
- Crawl — Googlebot fetches the URL i reads the raw HTML. A serwer-side 301/302/307/308 jest seen right here.
- Render queue — strony że zwracać
200wait to być wyrenderowany. Google’s docs note the strona “may stay on this queue for a few seconds, but it can take longer than that.” Google doesn’t publikować a fixed service-level timeline beyond że, so treat the wait as unpredictable — it może być quick, lub it może drag — rather than assuming dowolny specific liczba of days lub weeks. - Render + index — headless Chromium runs the JavaScript. ten jest the pierwszy moment a JS redirect exists as far as Google jest concerned.
The same idea I make on Crawling i in SEO JavaScript applies here: renderowanie jest a oddzielny krok z pobieranie, i anything że depends on it inherits że opóźnienie i że risk.
i the risk jest rzeczywisty. Google: “While Google attempts to render every URL Googlebot crawled, rendering may fail for various reasons. This means that if you set a JavaScript redirect, Google might never see it if rendering of the content failed.” (Google Search Central) podczas the window przed the redirect jest processed — i forever, if renderowanie fails — Google może zachowaj empty źródło strona in jego index.
Google’s official preference order
The redirects documentation lays out a hierarchy z najbardziej to least niezawodny:
- serwer-side redirects — 301/308 (permanent), 302/307 (temporary). Best dla everything: seen at crawl time, unambiguous.
- Meta refresh — HTML-level. A 0-second meta refresh jest treated as a permanent redirect (like a 301); dowolny delayed meta refresh jest treated as temporary.
- JavaScript redirects — ostatni resort.
Google’s words: “Only use JavaScript redirects if you can’t do server-side or meta refresh redirects.” Permanent redirects pass the canonical signal to the target; temporary ones zachowaj original in wyniki. (How że interacts z canonical selection jest ponad on Canonicalization.)
robi link equity pass przez?
Google’s own redirects documentation listy JavaScript location navigation among jego permanent redirection metody, i says the target becomes the canonicalization signal once Google ma interpreted it — so the flat “JS redirects don’t pass PageRank” twierdzenie jest fałszywy. co the documentation doesn’t establish jest że the outcome jest identical, immediate, lub as niezawodny as a serwer-side 301 — it describes the canonical signal, nie a guarantee of matching PageRank flow, ranking, lub timing. The honest framing: a 301 passes the signal at crawl time z near-certainty; a JS redirect passes it tylko if i gdy renderowanie succeeds, i Google doesn’t promise the wynik będzie match a 301’s outcome one-dla-one. że gap — nie lost equity — jest the rzeczywisty cost of choosing JavaScript.
ten jest również why JS redirects aren’t a penalty trigger on ich own. They tylko become a spam problem gdy they’re używany dla cloaking — showing crawlers one strona i redirecting użytkownicy to something różny, lub sending mobilny użytkownicy to an unrelated domain. Google’s sneaky redirects polityka jest o że intent, nie the technique.
gdy a JavaScript redirect jest the right narzędzie
There są legitimate cases:
- Constrained platformy. niektóre shared hosting, CDN, lub CMS setups give you no access to serwer-side redirect reguły. A JS redirect jest a prawidłowy fallback — i notably, Google używany JS redirects on ich own Webmaster blog ponieważ, as Gary Illyes put it, “that was the only thing we could use for 1:1 redirects, and it works on Google” (OnCrawl).
- SPA błąd handling. Google explicitly endorses ten: “Use a JavaScript
redirect to a URL for which the server responds with a
404HTTP status code.” (Google Search Central) A single-strona app że resolves a bad route może redirect to a rzeczywisty 404 endpoint so Google procesy the błąd correctly zamiast indeksowanie a soft 404.
dla permanent URL migrations, ten jest nie the narzędzie — używać a 301. I make the same point in migracje witryn: JavaScript redirects są a ostatni resort, i Google może nigdy see them.
statyczny witryna generators: the Hugo aliases trap
A common surprise: Hugo’s aliases: frontmatter ma historically generated
meta refresh HTML strony, nie serwer-side 301s — i other statyczny generators
mieć done similar things by domyślny. Generator defaults change między versions,
so sprawdzenie twój current deployed version’s rzeczywisty output zamiast assuming; if
aliases: isn’t giving you 301s, you need platforma-level redirect reguły (Netlify
_redirects, Cloudflare Workers, Vercel vercel.json) plus (on Hugo)
disableAliases: true. I cover ten in detail in
Hugo SEO.
implementacja dobre praktyki
If a JavaScript redirect jest genuinely twój tylko option:
- używać
window.location.replace(), nie.href. As wyszukiwarka Journal puts it, JS redirects “typically usewindow.location.replace()function rather thanwindow.location.hrefto avoid UX redirect loops” (SEJ). - Put it in the
<head>, nie the<body>. przeglądarki parse HTML sequentially i run scripts as they hit them, so “position JavaScript redirects in the<head>tag rather than<body>to minimize delay” (OnCrawl). - Redirect to the final destination in one hop. A JS redirect to a strona że itself 301s elsewhere makes a chain; chains waste budżet indeksowania i może surface in GSC as a redirect błąd.
- usuń źródło URL z twój mapa witryny XML. Sitemaps powinien lista canonical, indeksowalny URLs — nie redirecting ones.
- Repoint linki wewnętrzne at the destination, so they don’t route przez the redirect at wszystkie.
- upewnij się Googlebot może fetch the JS. If the redirect lives in an external
script blocked by
robots.txt, Google może’t render it i won’t see the redirect.
How to detect JavaScript redirects
They don’t announce themselves like a 301 in a header, so you mieć to render:
- A crawler z JS renderowanie on. OnCrawl recommends crawling z
“JavaScript rendering enabled (5-second timeout minimum)”; Screaming Frog i
Ahrefs witryna Audit może oba render. bez renderowanie, a JS-redirecting strona just
looks like a normal
200. - Chrome DevTools. The Network tab (z “Preserve log”) pokazuje the client-side navigation; the Redirect Path extension flags it too.
- In Search Console, a successfully processed JS redirect pokazuje up poniżej strona z redirect — the same status as dowolny redirected URL, który jest normal dla non-canonical źródła. że label isn’t guaranteed on dowolny given sprawdzenie, though: it reflects whatever Google fetched, wyrenderowany, interpreted, i canonicalized at the sampled moment, so a URL może pokazywać a różny status (lub no redirect status yet) między sprawdzenia bez że będąc an błąd on twój end.
co I’d actually robić
serwer-side pierwszy, każdy time. Meta refresh (0-second) gdy you może edit HTML ale
nie serwer config. JavaScript tylko gdy oba są off the tabela — i then z
window.location.replace() in the <head>, a clean mapa witryny, i a sprawdzenie że the
redirect actually renders dla Googlebot. dla anything permanent lub wysoki-wartość, the
extra reliability of a 301 jest worth almost dowolny effort to obtain.
AI summary
A condensed take on the Advanced version:
- A JavaScript redirect jest client-side (
window.location.replace(),.href,.assign()). It’s tylko processed po renderowanie — phase three of crawl → render → index — whereas a serwer-side 301 jest seen at crawl time. - The render queue jest the risk: a strona “may stay on this queue for a few seconds, but it can take longer,” z no fixed service-level timeline, i renderowanie może fail entirely, in który case Google może nigdy see the redirect i zachowuje the źródło strona zindeksowany.
- Google’s preference order: serwer-side (301/302/307/308) → meta refresh → JavaScript. Docs: “Only use JavaScript redirects if you can’t do server-side or meta refresh redirects.”
- The target becomes a canonicalization signal once Google interprets a JS redirect — so the “JS redirects don’t pass PageRank” myth jest fałszywy — ale Google doesn’t document że the outcome matches a serwer-side redirect’s PageRank flow, ranking, lub timing exactly. JS redirects aren’t a penalty trigger unless używany dla cloaking (sneaky redirects).
- Legitimate używa: constrained platformy (Google itself używany them on ich blog), i SPA błąd strony że redirect to a rzeczywisty 404 (Google-endorsed).
- Meta refresh ≠ JS redirect: it’s HTML-level; 0s = permanent, dowolny opóźnienie =
temporary.
history.pushState()/replaceState()aren’t redirects — no HTTP signal, crawlers don’t follow them. - Hugo
aliases:są meta refresh, nie 301s — a common trap on statyczny generators. - implementacja:
window.location.replace()in the<head>, single hop to the destination, remove źródło z mapa witryny, repoint linki wewnętrzne, zapewniać Googlebot może fetch the JS. - Detection: crawl z JS renderowanie on, Chrome DevTools / Redirect Path, “Page with redirect” in GSC.
Official documentation
Primary-źródło guidance on redirects i JavaScript.
- Redirects i Google Search — the preference hierarchy (serwer-side → meta refresh → JavaScript), permanent vs. temporary handling, i the meta refresh opóźnienie reguły.
- SEO JavaScript Basics — the render pipeline i the endorsed SPA-404 redirect używać case.
- Fix search-powiązany JavaScript problems — soft 404s, renderowanie, i debugging JS że Google może’t proces.
- Sneaky redirects (spam polityki) — gdy a redirect crosses do cloaking i becomes a polityka violation.
Bing / Microsoft
- Bing Webmaster pomagać — entry point dla Bing’s current guidance. (At the time of writing, Bing miał no dedicated redirects pomagać strona at a stable URL; Bingbot renders JavaScript mniej reliably than Googlebot, który makes JS-tylko redirects riskier dla Bing indexation.)
cytaty z the źródło
On-the-record statements z Google i the people who działać on Search. każdy Google-docs link jest a deep link że jumps to the quoted passage.
Google — the preference order i the renderowanie risk
- “Only use JavaScript redirects if you can’t do server-side or meta refresh redirects.” — Google Search Central docs. Jump to cytat
- “While Google attempts to render every URL Googlebot crawled, rendering may fail for various reasons. This means that if you set a JavaScript redirect, Google might never see it if rendering of the content failed.” — Google Search Central docs. Jump to cytat
Google — the endorsed SPA używać case
- “Use a JavaScript redirect to a URL for which the server responds with a
404HTTP status code (for example/not-found).” — Google Search Central docs. Jump to cytat
Gary Illyes, Google
- On JS redirects generally: “Js redirects are probably not a good idea though.” (July 8, 2020)
- On Google używając them anyway gdy nothing else worked: “We used JS redirects on webmasters.googleblog.com because that was the only thing we could use for 1:1 redirects, and it works on Google.” Coverage
wyszukiwarka Journal — implementacja i link equity
- “JavaScript redirects typically use
window.location.replace()function rather thanwindow.location.hrefto avoid UX redirect loops.” Read - “JavaScript redirects are not SEO-friendly and should be avoided when alternatives exist… Only implement JavaScript redirects when server-side alternatives are genuinely unavailable.” Read
Redirect types — cheat sheet
gdy Google sees it, i how it’s treated
| metoda | gdy Google sees it | Treated as | Reliability |
|---|---|---|---|
serwer-side 301 / 308 | Crawl time | Permanent | Highest |
serwer-side 302 / 307 | Crawl time | Temporary | Highest |
Meta refresh, 0 seconds | HTML parse time | Permanent | wysoki |
Meta refresh, delayed (>0s) | HTML parse time | Temporary | wysoki |
| JavaScript redirect | po renderowanie | Follows the navigation | Lowest |
history.pushState() / replaceState() | — | nie a redirect | n/a |
JavaScript redirect metody
| Code | History behavior | używać it? |
|---|---|---|
window.location.replace("url") | Removes źródło z history | Yes — recommended |
window.location.href = "url" | zachowuje źródło (back-button loop) | Avoid dla redirects |
window.location.assign("url") | Same as .href | Avoid dla redirects |
document.location.href = "url" | Alias dla .href | Avoid dla redirects |
Fast fakty
- Google’s order: serwer-side → meta refresh → JavaScript. używać JS tylko gdy the pierwszy two są impossible.
- Once interpreted, a JS redirect’s target jest a canonicalization signal — the “JS redirects don’t pass PageRank” myth jest fałszywy. Google doesn’t document że outcome as identical to a 301’s, so the rzeczywisty risk jest opóźnienie / render awaria, nie a udokumentowany PageRank penalty.
- JS redirects są nie a penalty unless używany dla cloaking.
- Hugo
aliases:= meta refresh, nie 301. - A processed JS redirect appears as “Page with redirect” in GSC.
powinien I używać a JavaScript redirect? — decision checklist
Walk ten top to bottom; stop at the pierwszy “yes.”
- może I ustawić a serwer-side
301/302/307/308? → robić że. Stop here. - może I edit the HTML
<head>ale nie serwer config? → używać a 0-second meta refresh dla permanent moves. Stop here. - Neither jest possible (locked-down platforma), lub it’s a SPA błąd strona że powinien hit a rzeczywisty 404? → A JavaScript redirect jest acceptable. Continue.
If you’re używając a JavaScript redirect
- używać
window.location.replace()(nie.href/.assign()). - Place the script in the
<head>, as early as possible. - Redirect straight to the final destination — no chain przez another redirect.
- usuń źródło URL z twój mapa witryny XML.
- Repoint linki wewnętrzne to the destination.
- Confirm the redirect’s JS jest nie blocked in
robots.txtso Googlebot może render it. - You są nie showing crawlers one strona i redirecting użytkownicy elsewhere (cloaking).
- Verify by crawling z JS renderowanie on i checking “Page with redirect” in GSC.
The recommended JavaScript redirect
Put ten in the <head> so it executes as early as possible in parse order:
<head>
<script>
window.location.replace("https://example.com/new-page/");
</script>
</head>replace() jest the key choice — it drops the redirecting URL z session history,
so the back button doesn’t bounce the użytkownik straight back do the redirect.
The 0-second meta refresh (następny-best gdy you może’t robić serwer-side)
nie JavaScript, ale the right fallback gdy you może edit HTML i nie serwer config. A 0-second opóźnienie jest treated by Google as a stałe przekierowanie:
<head>
<meta http-equiv="refresh" content="0; url=https://example.com/new-page/">
</head>co nie to używać as a redirect
history.pushState() rewrites the address bar ale performs no navigation i
wysyła no HTTP signal — crawlers won’t follow it:
// NOT a redirect — only changes the URL bar, no navigation happens
history.pushState({}, "", "/new-page/");If you need an SPA route change to być crawlable, give it a rzeczywisty <a href> link lub
a genuine navigation, nie just a History API call.
SPA błąd strona → rzeczywisty 404 (Google-endorsed pattern)
gdy a single-strona app resolves an nieznany route, wysyłać it to an endpoint że
zwroty an rzeczywisty 404 so Google procesy the błąd zamiast a soft 404:
// On an unresolved route in your SPA:
window.location.href = "/not-found"; // /not-found must return HTTP 404 narzędzia dla finding i checking JavaScript redirects
- Screaming Frog SEO Spider — enable JavaScript renderowanie (z a sufficient
renderowanie timeout) so JS-redirecting strony don’t just look like plain
200s. - Ahrefs witryna Audit — renders strony i surfaces redirects, chains, i redirected linki wewnętrzne.
- Chrome DevTools — Network tab — turn on “Preserve log” i watch the client-side navigation fire.
- Redirect Path (Chrome extension) — flags client-side redirects alongside serwer-side ones in a quick popup.
- Google Search Console — URL Inspection — see how a single URL był crawled i wyrenderowany, i whether Google landed on “Page with redirect.”
- GSC — strona indeksowanie raport — “Page with redirect” listy redirected URLs; “Redirect error” surfaces chains i loops.
Mistakes to avoid z JavaScript redirects
- używając
window.location.href(lub.assign()) zamiast.replace()..hrefzachowuje the redirecting strona in session history, so the back button bounces the użytkownik straight back do the redirect — a loop. robić instead: używaćwindow.location.replace(), który drops the źródło z history. - Reaching dla a JS redirect on a permanent, wysoki-wartość migration gdy a 301 jest available. JS redirects są tylko processed po renderowanie, który może być delayed lub fail outright — the błędny risk to take on a strona że matters. robić instead: używać a serwer-side 301; save JavaScript dla constrained platformy i SPA błąd strony.
- Chaining the JS redirect do another redirect zamiast landing on the final destination in one hop. Chains waste budżet indeksowania i może surface as a redirect błąd in GSC. robić instead: point the JS redirect straight at the destination URL.
- Leaving the źródło URL in the mapa witryny XML. Sitemaps powinien lista canonical, indeksowalny URLs, nie redirecting ones. robić instead: usuń źródło z the mapa witryny once the redirect jest live.
- Letting
robots.txtblok the script że fires the redirect. If Googlebot może’t fetch the JS, it może’t render the redirect, i the źródło strona może sit zindeksowany indefinitely. robić instead: confirm the script jest crawlable — the robots.txt tester sprawdzenia exactly ten. - Assuming Hugo’s
aliases:frontmatter gives you a 301. It ma historically generated a meta refresh HTML strona, nie a serwer-side redirect — verify twój deployed version’s rzeczywisty output zamiast assuming. robić instead: używać platforma-level redirect reguły (Netlify_redirects, Cloudflare Workers, Vercelvercel.json) plusdisableAliases: true, as covered in Hugo SEO. - Treating
history.pushState()/replaceState()as a redirect. They tylko rewrite the address bar — no navigation, no HTTP signal, i crawlers don’t follow them. robić instead: używać a rzeczywisty<a href>link lub an rzeczywisty navigation dla anything że needs to być crawlable. - Showing crawlers one strona i sending użytkownicy somewhere else (cloaking). ten jest co turns a legitimate JS redirect do a sneaky redirects polityka violation — it’s o intent, nie the technique. robić instead: wysyłać everyone, bots included, to the same destination.
Common problemy z JavaScript redirects
The źródło URL stays zindeksowany long po the redirect went live
- prawdopodobny cause: the strona jest nadal sitting in Google’s render queue, lub renderowanie failed outright.
- Fix + sprawdzenie: run a Live Test in Google Search Console’s URL
Inspection narzędzie on the źródło URL. If it hasn’t wyrenderowany yet, wait — Google
gives no fixed timeline dla the render queue, so recheck periodically rather
than assuming a specific window. If renderowanie zachowuje failing, confirm the
redirect script isn’t blocked (see the
robots.txtproblem below).
The back button zwroty straight to the redirecting strona
- prawdopodobny cause: the redirect używa
window.location.hreflub.assign()zamiast.replace(), so the źródło URL stays in session history. - Fix + sprawdzenie: switch the script to
window.location.replace(). Confirm by landing on the destination i pressing back — it powinien skip the redirect źródło entirely.
GSC pokazuje “Crawled – currently not indexed” zamiast “Page with redirect”
- prawdopodobny cause: Google hasn’t wyrenderowany the strona yet, lub renderowanie jest failing dla że URL.
- Fix + sprawdzenie: crawl the URL z a JS-renderowanie crawler (Screaming Frog lub
Ahrefs witryna Audit, renderowanie enabled) to confirm the redirect actually fires
client-side. również sprawdzenie że the redirect script isn’t blocked in
robots.txt— the robots.txt tester confirms whether Googlebot może fetch it.
An unresolved SPA route pokazuje up as a soft 404 in GSC
- prawdopodobny cause: the route redirects somewhere, ale the destination doesn’t
actually zwracać an HTTP
404status. - Fix + sprawdzenie: point the redirect at an endpoint że genuinely responds
z
404(Google’s endorsed pattern), then re-run URL Inspection to see the status change z soft 404 to a clean 404.
A JS-redirecting strona nadal looks like a plain 200 in a crawl raport
- prawdopodobny cause: the crawler ran bez JavaScript renderowanie enabled, so it tylko saw the initial HTML odpowiedź, nie the client-side navigation.
- Fix + sprawdzenie: re-crawl z JS renderowanie turned on (a 5-second timeout minimum jest a reasonable starting point) i confirm the redirect now pokazuje up.
Proving the redirect actually took effect
| Test to run | Expected wynik | awaria interpretation | monitorowanie window | Rollback trigger |
|---|---|---|---|---|
| robots.txt tester on the redirect script’s URL | Script jest Allowed dla Googlebot | Disallowed — Google może’t fetch the script, so it może nigdy render the redirect | Immediate | Fix lub usuń blocking robots.txt reguła przed relying on the redirect |
| Crawl the źródło URL z JS renderowanie enabled (Screaming Frog / Ahrefs witryna Audit) | Crawler raporty a client-side navigation to the intended destination | strona nadal raporty a plain 200 z no navigation — renderowanie isn’t firing | Immediate (single crawl) | If it nadal doesn’t fire po fixing robots.txt, używać a 0-second meta refresh lub serwer-side redirect instead |
| GSC URL Inspection — Live Test on the źródło URL | wyrenderowany wynik pokazuje the redirect executing to the destination | renderowanie fails, lub the wyrenderowany HTML pokazuje no navigation | Immediate dla the live test itself | If Live Test repeatedly fails to render, treat ten platforma as unable to obsługiwać a JS redirect — get serwer access lub używać meta refresh |
| GSC — strona indeksowanie raport dla the źródło URL | źródło URL jest listed poniżej “Page with redirect” | nadal pokazuje as zindeksowany, “Crawled – currently not indexed,” lub duplikat treści | 2–4 weeks (indeksowanie status updates on Google’s own schedule) | If nadal nie classified as a redirect po 4+ weeks, revisit the blokujący renderowanie sprawdzenia above |
| Manual back-button sprawdzenie in a przeglądarka po landing on the destination | Back button skips the źródło strona entirely | Back button zwroty to the źródło strona | Immediate | Switch the script z .href/.assign() to window.location.replace() |
Test yourself: JavaScript Redirects
Five quick questions on how JavaScript redirects działać i gdy to używać them. Pick an answer dla każdy, then sprawdzenie.
zasoby worth twój time
My powiązany writing
- SEO JavaScript problemy & dobre praktyki — the renderowanie side, który jest why JS redirects carry ich timing risk.
- The Beginner’s poradnik to techniczne SEO — gdzie redirects i renderowanie fit in the bigger picture.
My speaking
- How Search działa (SlideShare) — my walkthrough of crawling, renderowanie, indeksowanie, i ranking — the pipeline że makes a JS redirect a phase-three event. (My standing disclaimer applies: “This is my understanding of systems… not going to be 100% complete or accurate.”)
z around the industry
- Redirects i Google Search (Google Search Central) — the official preference hierarchy i permanent-vs-temporary handling.
- Sneaky redirects (Google Search Central) — the spam-polityka wiersz że separates a legitimate redirect z cloaking.
- JavaScript Redirects & SEO: gdy & How To używać Them (wyszukiwarka Journal) — practical implementacja guidance i the
replace()vs.hrefdistinction. - są JavaScript Redirects SEO-Friendly? (wyszukiwarka Journal) — the “avoid when alternatives exist” summary.
- JavaScript Redirects i SEO: The Ultimate poradnik (OnCrawl) — head-placement guidance, detection tooling, i the pełny Gary Illyes cytat.
- są JavaScript Redirects Bad dla SEO? (Conductor) — a concise FAQ-style answer dla the informational zapytanie.
- A poradnik to Redirect Types (Lumar) — broader redirect taxonomy z JS redirects in context.
Dziennik zmian
Zaktualizowano 18 lip 2026.
Podsumowanie redakcyjne i zapisane szczegóły zmian.Szczegóły zmian
-
Szczegółowe uwagi dotyczące zmian są obecnie dostępne po angielsku.
-
Szczegółowe uwagi dotyczące zmian są obecnie dostępne po angielsku.
-
Szczegółowe uwagi dotyczące zmian są obecnie dostępne po angielsku.
-
Szczegółowe uwagi dotyczące zmian są obecnie dostępne po angielsku.
Pełne porównanie jest niedostępne — dla tej wersji nie zarchiwizowano wcześniejszej migawki.