Today, I changed this blog hosting from Github pages to Netlify plateform
Earlier, I wrote the tutorial about How to deploy React App to GitHub Pages? The hosting platform of Github is awesome. It was easy to host. They have integrated continuous deployment so no need to change files on the server. When I commit to my branch it is directly deployed.
What is the reason to change?
The reason behind the changing plateform is SEO of my blog. I wanted to index my blog pages in search engine sites. You can find the tutorial on my blog about React is SEO friendly or not.
Above post was about 3 months ago. Since then, I have been trying to index my pages on Google. But, there was no luck. I'm getting only two results of my website.
React was not a problem
Turns out, react was not a problem at all. So, whose problem it is. I can say that this problem is a combination of Github Pages and my programming (LOL) and Google crawlers. Yeah, that's true. Let me explain it in more detail.
1) Github Pages
When I hosted my first blog on Github Pages, I face the problem of 404 when I refresh the blog page. It can't find the index.html file on the server on that route. You can find more detail here: SPA host on Github.
2) Programming
However, I found the easy solution that we can use HashRouter to generate the links. I changed the code according to that. So, URLs will change from http://kepy.online/blog/surviving-finals-week to http://kepy.online/#/blog/surviving-finals-week.
3) Google crawlers
I didn't have the problem with hash-based URL. But, Google can't index those URLs. I got to know after I posted a question on google webmaster community. Question: URL can be indexed: Still many pages not showing in Google
Solution
As you can see, the problem generated due to multiple factors. I came up with a different solution like I can use query string as URL to find the specific route. But, I was looking for a permanent solution. Then, I got to know about Netlify.
Netlify is an all-in-one platform for automating modern web projects. It is very easy to deploy react website on Netlify. Also, it has a free plan and solves 404 Github pages error using "_redirects" file. Follow this tutorial to host on Netlify.
Now, everyone is happy. I hope google to index my pages in a few days. Wish me luck :)
Keyul Patel is a 23-year-old computing student who enjoys eating out, relaxing and outdoor activities. He is helpful and loveable. He is currently at college studying computing. He is obsessed with programming.