56

Does it make any difference to SEO ratings what-so-ever if your url has a trailing slash:

http://www.example.com/some/slug/paths/

as opposed to one that does not:

http://www.example.com/some/slug/paths
1

4 Answers 4

44

Read the full blog post by Google here, http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html, it covers this exact topic.

Long story short Google does not care if you have a trailing slash. However, it will treat the below 2 paths as separate pages.

http://www.example.com/some/slug/paths/
http://www.example.com/some/slug/paths

If you need to have both of the above and they are the same content your best option is to do a 301 Redirect to one of them from the other.

If that isn't an option you will want to add a <link rel="canonical" href="your link"/> to both pages which will define which one is the master or parent. Matt Cutts has a great article here, http://www.mattcutts.com/blog/canonical-link-tag/, that covers the topic in its entirety.

4
  • That is good practice anyway, because you never know what people will put as the URL when linking to you. I'd hate to get a permanent link on a PR8 site that was not to my canonical URL :)
    – Tim Post
    Commented Aug 24, 2010 at 13:52
  • 3
    This is not really what the canonical tag is for. The correct thing to do is to 301 redirect the slash version to the non-slash version (or vice versa, depending on which you want), which is exactly what the Google webmaster central blog entry you linked suggests. Use a canonical here only if a 301 is not possible. Commented Aug 24, 2010 at 14:46
  • @Tim - Good point. You are right, the canonical is only the backup choice. I modified my answer to be more correct. Thanks! Commented Aug 24, 2010 at 14:55
  • 2
    Server side applications also treat the paths differently. In Django, domain.com/some will be redirected to domain.com/some/. Something to keep in mind. :) Commented Aug 24, 2010 at 15:04
9

In addition to RandomBen's point about search engines treating URLs with a trailing slash versus without as two different URLs, I'd like to add this. I generally use the trailing slash to indicate a category, while I don't use a trailing slash for pages that are at the end or bottom of a hierarchy. Slash your categories, don't slash anything else. If you're rewriting URLs, this most closely matches the natural file structure. However, you should make sure that each category in your path exists, or you could end up with some confused and frustrated users. In your example URL, "some" and "slug" should both be accessible pages.

2
  • That can be quite reasonable. If you want to emulate a file system in your URLs, would it then perhaps be neater to 'go all the way', and give your stub pages a (possibly fake) extension, like .html or .py, .pl, .asp, or something else. Just having no trailing slash does not communicate "stub page" to me, it could just have been forgotten -- but a "file" extension does.
    – user1857
    Commented Sep 4, 2010 at 21:51
  • @Jesper "Who says a file name needs an extension?? take a look on a *nix machine sometime" -stackoverflow.com/questions/5948659/…
    – Yarin
    Commented Oct 31, 2011 at 23:03
6

There is one case in which a trailing slash will help with search engine optimization (SEO). That is the case that your document has what appears to be a file extension that is not .html. This becomes an issue with sites that are rating websites. They might choose between these two urls:

  • http://mysite.example.com/rated.example.com
  • http://mysite.example.com/rated.example.com/

In such a case, I would choose the one with the trailing slash. That is because the .com extension is an extension for Windows executable command files. Search engines and virus checkers often dislike URLs that appear that they may contain malware distributed through such mechanisms. The trailing slash seems to mitigate any concerns, allowing the page to rank in search engines and get by virus checkers.

If your URLs have no . in the file portion, then I would recommend omitting the trailing slash for simplicity.

(This is the same answer I posted on StackOverflow)

1

URL's with and without slashes are treated as two different URL's. Its absolutely essential that you fix this to avoid duplicate content problems. Generally, this affects the whole site, as every page has a duplicate.

  1. Standardize site wide URL's
  2. Use 301 redirects or canonicalization to fix URL's
  3. Do an internal link audit to make sure there are no unnecessary redirects and all internal links point to standardized URL's.
  4. You may also check external links. Ideally they too should point to standardized URL's.

See rankings improve.

Not the answer you're looking for? Browse other questions tagged or ask your own question.