Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a splash page hosted in github pages for a client while we finish their official site.

Until a few days everything was ok but I now realized that google is indexing the github url instead of the custom domain.

I followed github instructions, i used the CNAME file in my repo, I setup the A domain for the top-level domain and the CNAME for the www. I looked all over the internet without luck. I tried using google webmaster tools, and I can't really use robots.txt because that would affect both.

like image 883
bravomartin Avatar asked Dec 20 '22 08:12

bravomartin


1 Answers

I think I found the solution. Leaving it since it might be helpful to others.

I need to wait now for google to re-index, but it should do it. According to this question and this google article a canonical link tag in the head should fix it.

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

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

if ( window.self === window.top ) { 
    // console.log("not in a frame") 
       window.location.href = 'http://www.[website-url]';
    }
like image 156
bravomartin Avatar answered Dec 27 '22 05:12

bravomartin