You are here » Home » Blogging » How to redirect 404 Error (Page Not Found) to homepage in Blogger

How to redirect 404 Error (Page Not Found) to homepage in Blogger

by Nitin Maheta

404-not-found-error-54
When a user lands to a nonexistent or deleted URL on your blog, Blogger will display this Error 404 (Page Not Found) i.e. “Sorry for the inconvenience, the page you are looking for has no existence”. This may be a shot of loosing a blog reader. In light of the fact that just not many users will think to move at home page or use search bar to inquiry that specific content on your blog. I am sure many of reader will leave your blog and move again to their search items. Before you loose your new reader for your blog you should redirect to a reader to homepage (or any post page) when comes to a deleted or nonexistent page or post of your blog. so, there is 2 ways to we can redirect 404 page to homepage. one of the way to redirect is to use meta refresh and second method is by using JavaScript. so, personally i don’t like to add JavaScript because it’s effect to blogger loading time. that’s why I’m not recommended you to use JavaScript method for it. but here i show you both method you can use one method as you preferred form it. (meta tag refresh – recommended)

Also Read:- New Javascript ~ Automatically Redirect A Blogger Blog To Another URL

Method : 1 Meta Tag Refresh ( Recommended )

Go to Blogger Dashboard › Select a blog › Switch to Template tab › Edit HTML
Now search for <head> tag (using CTRL + F )
Copy and paste below code just below/after <head> tag

<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://www.your-blog-url.com' http-equiv='refresh'/>
</b:if>

blogger head tag

Note : Change http://www.your-blog-url.com with your blog homepage URL

Finally save your template  › Done.

Method: 2 Using JavaScript

Go to Settings › Search Preferences › Custom Page Not Found ( under Error and redirections)
Click Edit and paste below code :

Sorry, the page you were looking for in this blog does not exist. You will be redirected to homepage shortly.
<script type = "text/javascript">
//Blogger 404 Redirect v1.0 (makingdifferent.com)
BSPNF_redirect = setTimeout(function() {
location.pathname= "http://www.your-blog-url.com/"
}, 5000);
</script>

bloggger
Note : Change http://www.your-blog-url.com/ with your blog homepage URL  and 5000 is the delay time in Milliseconds. Anyone can change it. Changing the value to Zero (0) would redirect immediately. (no delay)
Click Save Changes › Done.

Also Read:- Hide/Show Widgets/Gadgets in Home/post/static/archive pages in Blogger

Now you can test the error page code is working by entering URL that doesn’t exits in your domain. (e.g. http://your-blog-url.com/404 )