What we think

Should URLs include a trailing slash for SEO?

We sometimes get asked whether each URL should end with or without trailing slash.

For example:

Two URLs

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 because it can impact page load speed.
From Yahoo! Developer Network:

The main thing to remember is that redirects slow down the user experience. Inserting a redirect between the user and the HTML document delays everything in the page since nothing in the page can be rendered and no components can start being downloaded until the HTML document has arrived.
One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to http://astrology.yahoo.com/astrology results in a 301 response containing a redirect to http://astrology.yahoo.com/astrology/ (notice the added trailing slash). This is fixed in Apache by using Alias or mod_rewrite, or the DirectorySlash directive if you’re using Apache handlers.

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 for SEO outside of the page load speed elements of Google’s ranking algorithm.

Here’s a summary of Google’s advice:

  • Implement 301 (permanent) redirects from one version to the other through your .htaccess file.
  • 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:

edit.co.uk/product.html
edit.co.uk/product.aspx

*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 it’s preferable to use a trailing slash at the end of your URLs because page load times will improve slightly.

Related posts