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.
This code has 3 parts –
- Blogger error pageType tag
- Meta refresh tag
- Custom Error 404 (Page not found) message
1. Blogger error pageType tag
<b:if cond='data:blog.pageType == "error_page"'> ..... //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 == "error_page"'> 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?
-
- Go to Blogger Dashboard › Select a blog › Switch to Template tab › Edit HTML
- Now search for <head> tag
- And paste error page code just below head tag
- Save the template › Done
- 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! :)
अच्छी जानकारी !!
@PooraN, Swagat hai!
laga liya
@Manu, Enjoy!
Helpful, Thanks bhai
Most welcome :)
Thank u. Its really useful
Welcome Vishnu ji…
Woohoo, nice useful post … thankyou
Thanks a lot, this is the best technique i have ever seen and applied, it worked like a charm for me
Does Google delete the blog for using meta refresh?
thank you very much!!
wow, this was very helpful, thanks.
this have given me nightmare.
but i finally resolved it
Thanks it works
Thanks, It Work
awesome !!!
Great article. It helped me a lot !!! Thanks
Niche tutorial, 100% works!!!
Thanks. I just tried this trick and very helpful.