Tutorial

How to Add Automatic Redirect Code in Blogger or Any Website

If you have ever moved a page, retired an old URL or wanted to push visitors straight to a new tool, you need an automatic redirect. This guide shows exactly where to paste the snippet in Blogger, in a static HTML website, or inside a theme file — plus the SEO pitfalls you must avoid.

What is an automatic redirect code?

An automatic redirect code is a tiny block of HTML and JavaScript that tells the browser to instantly navigate away from the current page and open a different URL. The visitor does not click anything — the moment the page starts loading, they are moved.

The snippet you usually see looks like this:

<!-- Automatic Redirect Code Start -->
<script type='text/javascript'>
  window.location.href = "https://example.com/new-page";
</script>
<meta http-equiv="refresh" content="0;url=https://example.com/new-page.html"/>
<!-- Automatic Redirect Code End -->

It contains two independent mechanisms that do the same job:

  • JavaScript window.location.href — fires immediately when the script runs.
  • Meta refresh — an HTML fallback that also works with JavaScript disabled.

Using both together is the safest approach because if one fails, the other still redirects the visitor.

How to add it in Blogger

Blogger gives you three places to inject code, depending on whether you want to redirect a single post, a page, or the entire blog.

Option 1 — Redirect a single post or page

  1. Open Blogger and go to Posts → New post (or Pages → New page).
  2. Switch the editor from Compose view to HTML view (the pencil / HTML toggle at the top-right of the editor).
  3. Paste the snippet at the very top of the editor, before any other text.
  4. Replace the example URL with your destination URL in both lines.
  5. Publish the post. Open it in a private tab — the redirect fires instantly.

Use this when you want a specific Blogger URL (for example /2024/03/old-post.html) to send visitors to a newer post or a landing page on another domain.

Option 2 — Redirect the whole blog

  1. In Blogger, go to Theme → Edit HTML.
  2. Find the opening <head> tag using Ctrl+F.
  3. Paste the redirect snippet right after <head> and before <b:skin>.
  4. Save the theme. Every page on the blog will now redirect.

Be careful — this is a site-wide redirect. If you ever need to access the Blogger dashboard, do it from blogger.com directly, not from the public blog URL.

Option 3 — Add it inside a widget or HTML gadget

Widgets are handy when you want to redirect only from a specific sidebar link. Add an HTML/JavaScript gadget and paste the snippet inside. Note that widget redirects only fire once the widget renders — for instant behaviour, always prefer Option 1 or 2.

How to add it in a static HTML website

For a plain HTML site (or a framework that lets you edit the raw head), paste the snippet inside the <head> section of the page you want to redirect:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Redirecting...</title>

  <!-- Automatic Redirect Code Start -->
  <script type='text/javascript'>
    window.location.href = "https://technozaibi.com/tools/images/app-icon-generator";
  </script>
  <meta http-equiv="refresh" content="0;url=https://technozaibi.com/tools/images/app-icon-generator.html"/>
  <!-- Automatic Redirect Code End -->
</head>
<body>
  <p>Redirecting to the <a href="https://technozaibi.com/tools/images/app-icon-generator">App Icon Generator</a>...</p>
</body>
</html>

Three rules to keep in mind:

  • Place the snippet as high inside <head> as possible so the browser executes it before rendering the rest.
  • Add a visible fallback link in the <body> so a visitor is never stuck if redirects are blocked.
  • Never chain redirects — page A → page B → page C slows the browser and can loop.

How to add it on WordPress, Shopify and other platforms

PlatformWhere to pasteBest practice
WordPressCustom HTML block or a plugin like RedirectionPrefer the plugin — it issues a true 301
ShopifyOnline Store → Navigation → URL RedirectsUse the built-in redirect tool, not JavaScript
WixDashboard → SEO → URL Redirect ManagerBuilt-in redirect manager handles 301s
WebflowProject Settings → Hosting → 301 RedirectsServer-side redirect, best for SEO
Static HTMLInside <head>JS + meta refresh fallback (as shown above)

SEO warning — JavaScript redirects are temporary

Search engines treat a JavaScript or meta-refresh redirect as a temporary signal. That means:

  • Ranking signals from the old URL are not fully passed to the new URL.
  • The old page may stay in the index for weeks.
  • Featured snippets and rich results may not transfer.

If your goal is a permanent URL change, always use a server-side 301 redirect instead. On Apache that means an .htaccess rule; on Nginx it means a return 301 line; on a static host like Netlify or Vercel it means a redirects file. Use the JavaScript snippet only when you truly cannot access the server — for example inside Blogger posts or third-party embeds.

Common use cases

  • Moving an old blog post to a new slug while keeping the URL you shared on social media.
  • Sending a retired landing page to a relevant newer tool.
  • Redirecting mobile visitors to an app deep link.
  • Splitting traffic by country or language using navigator.language before redirecting.
  • Running time-limited campaigns where the promo page should vanish the moment the offer ends.

Testing your redirect

  1. Open the source URL in an incognito window — cached pages can hide the redirect.
  2. Check the browser address bar updates and the destination renders correctly.
  3. In Chrome DevTools, open the Network tab and confirm the redirect fires without errors.
  4. For SEO, use Google Search Console's URL Inspection tool to see how Google treats the redirect.
  5. Set up a 404 monitor for the first month to catch broken in-between links.

Frequently asked questions

What is an automatic redirect code?

It is a small snippet that sends a visitor from one URL to another the moment the page loads, without them clicking anything. It combines a JavaScript window.location line with a meta refresh tag as a fallback.

Can I add a redirect to a Blogger post?

Yes. Open the post in HTML view in Blogger and paste the snippet at the very top of the editor, then publish. The redirect runs the instant the post loads.

Is a JavaScript redirect bad for SEO?

JavaScript and meta refresh redirects are treated as temporary and do not pass full ranking signals. For permanent URL changes always use a server-side 301 redirect when you control the server.

Why does my redirect not work after publishing?

Common causes: the snippet was pasted in the body instead of the head, a caching plugin served the old version, a browser extension blocked the JavaScript, or the destination URL has a typo. Clear the cache and test in incognito mode.

Conclusion

An automatic redirect is a one-line fix that saves broken links, moves traffic instantly and keeps your site tidy. Paste the JavaScript plus meta-refresh snippet near the top of the <head> (or at the top of a Blogger post in HTML view), always include a fallback link, and remember: when you can use a real 301, use it instead.

Next step: if you are redirecting to a tool page, try our App Icon Generator — a good example of a destination page that is worth redirecting to.