How To Redirect 404 Error Pages To Homepage In Blogger

 

To redirect 404 error pages to your homepage in Blogger, you can add a custom JavaScript code to your theme. Here's how to do it:

  • Log in to Blogger: Go to your Blogger dashboard.
  • Select Your Blog: Choose the blog where you want to make the changes.
  • Go to Theme: In the left sidebar, click on "Theme."
  • Edit HTML: Click on the "Edit HTML" button to access the code editor.
  • Find the Closing </head> Tag: Use Ctrl + F (or Cmd + F on Mac) to find the </head> tag in the HTML code.

  • Insert the JavaScript: Just above the </head> tag, insert the following code:

<script type="text/javascript">
    window.onload = function() {
        if (document.title === "404 Not Found") {
            window.location.href = "/";
        }
    };
</script>
  • This script checks if the title of the page is "404 Not Found" and redirects to the homepage if it is.
  • Save Changes: Click on the "Save" button to apply your changes.
  • Test the Redirection: Open a new tab and try to access a non-existent page on your blog to see if it redirects to the homepage.
  • That's it! Your 404 error pages should now redirect to the homepage.

Post a Comment (0)
Previous Post Next Post