Pixel Mamelon
KPCKevin Powell - Community
•Created by Pixel Mamelon on 10/16/2024 in #os-and-tools
How to Prevent Netlify Subdomain from Being Indexed ?
Thank you for the share!
8 replies
KPCKevin Powell - Community
•Created by Pixel Mamelon on 10/16/2024 in #os-and-tools
How to Prevent Netlify Subdomain from Being Indexed ?
I haven’t started using them yet (but I will) .Instead, I added an A record and CNAME to the client’s domain registrar because I didn’t want to risk touching any email-related records at this point. Adding the A record was a bad idea (for anyone reading this, it's better to use an ALIAS instead, if possible).
While the solution you shared (redirects) is great, I was hoping to avoid losing myproject.netlify.app. I actually found it pretty helpful when the main site was down. Maybe I’ll try to figure out Netlify previews instead if nothing else works ,and let it go.
Another possible solution I found, suggested by ChatGPT, is to add a conditional meta tag using a script (Netlify snippet injection). Since the current version of the site is built with plain HTML while the rest of the site is still being developed, this approach would theoretically work. But I’m wondering if anyone is familiar with something like this as I don't see it in documentation..
<script>
if (window.location.hostname === 'domain.netlify.app') {
const meta = document.createElement('meta');
meta.name = "robots";
meta.content = "noindex";
document.head.appendChild(meta);
}
</script>
8 replies