Auto Redirect to Homepage If Page Not Found on A Blogger Blog

When any reader comes to your blog and unexpectedly does not get the searched post then error 404 (Page not found message) occurs and a message appears on page “Sorry, the page you were looking for in this blog does not exist.” by default. This may be a chance of losing a blog reader. Because only a few readers will think to move at home page or use the search bar to search that particular content on your blog. I am sure many of readers will close the window and move again to search results.

If Page to Found Redirect Reader to the Homepage

Before you lose an opportunity to make a new reader for the blog you should redirect to a reader to the homepage when comes to a nonexisting page or post of your blog. There are already few solutions available for redirecting a user to the main page or home page, one the method is JavaScript and other is meta refresh/redirection. I personally do not like adding more JavaScript to blog because it slows down the blog and reduces the blog performance. So for auto-redirecting Blogger Page not found (Error 404) page to the homepage, I am using meta refresh tag because it will load in the template only when any reader reaches to a non-existing page or error 404 occurs and does not reduce the blog performance.

Page not found Redirect to homepage

This code has 3 parts –

  1. Blogger error pageType tag
  2. Meta refresh tag
  3. Custom Error 404 (Page not found) message

1. Blogger error pageType tag

<b:if cond='data:blog.pageType == &quot;error_page&quot;'>
.....
//some code here
.....
</b:if>

2. Meta refresh/ redirection tag

<meta content='5;URL=https://your-blog-url' http-equiv='refresh'/>

3. Custom error 404/ page not found message

Oops! Page Does Not Exist. We are redirecting you to home page.

Now a complete code of error page is:

    <b:if cond='data:blog.pageType == &quot;error_page&quot;'>
    Oops! Page does not exist. We are redirecting you to home page.
    <meta content='5;URL=http://your-blog-url' http-equiv='refresh'/>
    </b:if>

Note: You must change http://your-blog-url with your blog URL.

How use this code in Blogger template?

    1. Go to Blogger Dashboard › Select a blog › Switch to Template tab › Edit HTML
    2. Now search for <head> tag
    3. And paste error page code just below head tag
    4. Save the template › Done
    5. You can test the error page code is working by opening following URL.
https://your-blog-url/404

Note: You must change your-blog-URL with your blog URL.

Happy Blogging! :)

19 thoughts on “Auto Redirect to Homepage If Page Not Found on A Blogger Blog”

  1. Avatar photo
    Susovansi Mishra

    Thanks a lot, this is the best technique i have ever seen and applied, it worked like a charm for me

  2. Avatar photo
    weight loss

    wow, this was very helpful, thanks.
    this have given me nightmare.
    but i finally resolved it

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top