We sometimes get asked whether each URL should end with or without trailing slash. For example:
So does it matter if my URLs include a trailing slash?
The short answer: either is fine, as long as its consistent…but if there’s no risky change to URLs involved (e.g. you’re launching a new website for the first time) we’d recommend using a trailing slash.
Theoretically a URL with a trailing slash implies a directory and a URL without a trailing slash is a file, but this isn’t really important anymore.
Google gave their answer in 2010. It starts like this:
Google treats each URL above separately (and equally) regardless of whether it’s a file or a directory, or it contains a trailing slash or it doesn’t contain a trailing slash.
…and ends like this:
Profit! (just kidding) But you can bask in the sunshine of your efficient server configuration, warmed by the knowledge that your site is better optimized.
So let’s assume it doesn’t really matter that much.
Here’s a summary of Google’s advice:
- Implement 301 (permanent) redirects from one version to the other
- If you can’t use permanent redirects, use canonical elements instead – either will reduce the risk of duplicate content
- Be consistent with your choice.
Google also suggests you can just leave the duplicate versions and Google will figure it out. That’s technically true in the sense that only one version will rank – but it also won’t rank as well as it should (and causes lots of other problems) so it’s always worth removing the duplicate.
Should I change URLs with extensions e.g. /product.html?
Whether or not to use a trailing slash becomes a moot point when URLs end with a file extension, such as:
*Not real URLs.
Again, search engines’ understanding of URLs with or without file extensions is the same – so URLs ending with .html aren’t causing problems, for example.
There are advantages in not using file extensions though:
- The ability to change technology (e.g. moving to .php, not that you’d do it) without having to change your URLs
- Direct visits will probably start on a clean URL (no extension) if typed, which will result in a redirect, slowing everything down slightly – the same can be true of links, which means your redirects have to be spot on (301 not 302; no redirect chains)
- Anecdotally URLs without extensions get a better click through rate (CTR) because they “look cleaner” in search results.
The advantages probably don’t outweigh the risks of migrating your URLs to lose file extensions so there aren’t many cases I would recommend doing it – unless you’re already changing your URLs (moving from HTTP to HTTPS, for example).
If you’re launching a brand new site it’s best practice not to include file extensions on your URLs.
In either scenario: you should choose a preferred URL and stick with it – but if you have the opportunity to choose a trailing slash, you should.