Hello! Got a problem I’m not sure what to do with.
We wrote a new site from scratch and hosted it on netlify for several months whilst testing. The site is live here; http://stoic-kilby-4274cc.netlify.app/
The problem we have is that both sites are now indexed and findable on Google. This is causing issues with search rankings. We have set the canonical on every page so that it points to the correct domain.
Normally I would use robots.txt to remove a site from Google but I think in this case it would result in both sites being removed.
Google usually removes these URLs within 24 hours in my personal experience, but if there are a lot of pages, it might take time. You can try searching for your website (with site: prefix) to confirm that it has been removed from index. Then change your Netlify site name. This will result in the old website returning a 404 and thus, even after 180 days, Google won’t be able to see it. It will eventually be permanently dropped from index.
Additionally, if you setup a 301 redirect, that would do the trick too. Finally, you can also use the change of address option in the search console.
@jonpreececm Just to amplify what @hrishikesh wrote, doing a redirect from your Netlify subdomain to your custom domain, along with having the correct canonical meta tags on each page, will go a long way toward resolving this issue, in my experience. Google will eventually catch up, but in the meantime you will be able to reap the rewards of search results to either URL.
This forces any request for the site subdomain under netlify.app to be 301 redirected to the custom domain. It forces the domain to change while keeping the path portion of the URL unchanged.
If there are other questions about this, please let us know.