How to make google index my custom domain instead of github domain?

I have a splash page hosted on github pages for a client when we finish the official site.

Until a few days everything was fine, but now I realized that google indexes github instead of a custom domain .

I followed the github instructions, I used the CNAME file in my repo, I configure domain A for the top-level domain and CNAME for www. I looked around the world with no luck. I tried using Google’s webmaster tools and I can’t use robots.txt because it will affect both.

+4
source share
1 answer

I think I found a solution. Leave it as it may be useful to others.

I need to wait now for Google to reindex, but it needs to. In accordance with this question and this google article, the canonical link tag in your head should fix it.

<link rel="canonical" href="http://www.[website-url]"/> 

I also added the js redirect trick to redirect people from google.

 if ( window.self === window.top ) { // console.log("not in a frame") window.location.href = 'http://www.[website-url]'; } 
+10
source

Source: https://habr.com/ru/post/1469011/


All Articles