Home
Support Forums

Netlify redirects and SEO

I’ve tried my best to find information on this topic online, but it doesn’t seem to cover what I’m looking for.

Ideally, we want to achieve two things:

  1. redirect the .html versions to the pretty URL non HTML versions, e.g. /contact.html to /contact.
  2. redirect trailing slash version to non trailing slash version, e.g. /contact/ to /contact (or vice versa).

I understand we can use canonical headers or HTML tags to point Google to the preferred URL. The outcome of this is Google should group those URL’s together as the same content, and attribute the rank power to them as a group, displaying only the preferred one in Google. However many in the SEO community seems to be in agreement that although according to Google this is the way to avoid issues with duplicate content, in practise Google doesn’t always apply these rules consistently and will sometimes end up indexing multiple URLs to the same page, therefore splitting rank power between them and damaging SEO. With this in mind, 301 redirecting is better to eliminate the risk.

I also dislike Netlify’s view that ‘if you don’t want Google to find these then don’t link them anywhere’. This is very close to ‘security through obscurity’, and it would be far better to eliminate the risk by redirecting, then to simply have to assume that link will never be found or shared.

So, I have a few questions:

  1. Is the above redirect rules possible in Netlify, and does Netlify have a reason for not recommending redirects as I mention above. I saw reference to Netlify saying something regarding cache hit rate, but what does this mean in practise?

  2. Regarding the netlify.app site, are we able to password protect this, but leave the custom domain version live, either via access control or HTTP Basic Authentication? Again, we want to avoid this ever being publicly accessible especially by Google.

  3. What are the reasons Netlify doesn’t allow you to disable this netlify.app URL? It does seem odd to not have the choice. I know Netlify say it’s for testing purposes, but why not just give us the choice?

I’m already sold on the platform, and I want to move a load of websites to Netlify for hosting, but I just can’t do this until we know SEO efforts will not be effected.

Or - am I wrong? And if I make sure on all pages they have a self referencing canonical tag to the URL of my choice… e.g. /contact (without .html and without trailing slash), there is no chance Google will rank anything but my preferred URL? The reason I’m hesitant to trust this is it leaves you at the mercy of Google rather then controlling the outcome yourself. And unless ‘no chance’ means ‘no chance’, then you’re not able to reliably control the outcome and that is an issue.

2 Likes

Hey there, @DanielFew :wave:

Thanks so much for reaching out and writing such a detailed post. I want to assure you we haven’t forgotten about your questions. I have looped in one of our Support Engineers who has a deep knowledge of redirects and will be able to answer with more depth than I am capable of. Stay tuned!

1 Like

Thanks @hillary that’s great!

1 Like

Hey @DanielFew, saw your question in our Helpdesk a little earlier. I send a response but, for posterity, here’s the resources which I think will help you (and others) find the answers you need:

1 Like

Hey there @DanielFew :wave:

I second @Scott and recommend you read those guides! I’ll do my best to direct-answer your questions above, but you ought to read through everything else as to the ‘why’ behind it.

Ideally, we want to achieve two things:

  1. redirect the .html versions to the pretty URL non HTML versions, e.g. /contact.html to /contact.

If your static site generation process results in a file named contact.html then it will be available at both /contact and /contact.html. I don’t currently believe there’s a way around that… but that particular side-effect is as old as web-servers and not an uncommon thing. While Google may have SEO effects from having content on both a trailing slash and non-trailing slash variant of a URL path, Google does not (to my knowledge) care and/or impact SEO if there’s content at a variant with a dot-type file ending. If you want to get technical, every single webpage URL on the internet should end in .html :stuck_out_tongue_winking_eye: but that’s just internet history.

You can switch and go the other route of having the static site generator instead generate a directory named contact with an index.html inside — but this is the “use trailing slashes” route, not the “don’t use trailing slashes” route (and while /contact and /contact.html will both redirect to /contact/, you can still manually request /contact/index.html and it resolves :stuck_out_tongue:)

  1. redirect trailing slash version to non trailing slash version, e.g. /contact/ to /contact (or vice versa).

You can do either for sure but think of it less like “wiring up redirects” and more like “Netlify just behaves one way or the other based on whether you’re giving it files vs. directories”. Files are served without trailing slashes. Directories with index.html files are served with trailing slashes. That’s traditional web parlance and not at all a function of redirects.

in practise Google doesn’t always apply these rules consistently and will sometimes end up indexing multiple URLs to the same page, therefore splitting rank power between them and damaging SEO

Classic Google :sunglasses: I agree though and that’s why I’ve written extensively about how to unify a site on a trailing slash strategy, specifically on Netlify. The guide Scott linked to contains links back to one or two of my posts, but in case you’d like to check them out for further context, they’re here:

Regarding the netlify.app site, are we able to password protect this, but leave the custom domain version live, either via access control or HTTP Basic Authentication? Again, we want to avoid this ever being publicly accessible especially by Google.

This is a case where a redirect is great and super easy to wire up. I do it for basically all of the sites I host on Netlify. For instance, my primary website, jonsully.net, holds the netlify.app subdomain of jonsully.netlify.app. In my _redirects file I simply have this line to force any traffic that attempts to hit the netlify.app subdomain site back to my primary domain:

https://jonsully.netlify.app/*   https://jonsully.net/:splat   302!

I use a 302 instead of a 301 but I’ll leave that to you. Now, it’s worth noting that there’s no real reason to do this outside of vanity — Netlify already adds request headers and Dom elements that indicate your custom domain as the canonical domain for the site when someone hits it through the netlify.app subdomain, but I digress.

The reason I’m hesitant to trust this is it leaves you at the mercy of Google rather then controlling the outcome yourself.

I would agree with you here, friend.

Hope that helps!


Jon

2 Likes

Thank you for the fantastic insight, @jonsully. We appreciate you taking the time to share those resources and ideas.

1 Like

No problem at all! Happy to help :smiley:

1 Like