Ludovic Frank - Freelance developer

The URL is an integral part of SEO. Does it have to end with a slash?

ionicons-v5-k Ludovic Frank Jan 18, 2021
60 reads Level:

What is a slash?

Let's start by explaining what a slash is. A slash is simply the slash found in Internet addresses, which is simply "/". It's also found in file paths on Unix-based operating systems (such as macOS) or Linux (such as Ubuntu). On Windows, the convention is for file paths to use backslashes, i.e. the same slash, but the other way round.

A little history.

In the past, putting a slash in Internet addresses made it possible to differentiate a "file" from a "folder".I use quotation marks, because a folder on the web is a page, but what we call a folder would be a page representing all the articles on a blog, for example "https://symfony.com/blog/" and a file is a single article, for example "https://symfony.com/blog/a-week-of-symfony-733-11-17-january-2021". I've used the Symfony blog on purpose, as it always uses this convention.
Nowadays, search engines are sophisticated enough to ignore the slash at the end of a URL to differentiate a file from a folder. Using the slash for this purpose is no longer necessary.

Avoid duplicate content on the Internet

To do this, you need to understand how web addresses work, and we're going to use this tweet, which explains things very well. What's more, it comes from someone who works at Google, so the guy knows his stuff.
What you need to understand here is that you can't have two addresses returning the same content, because then it's called duplicate content and it's very bad for the SEO of said content.

The protocol

In a URL, the protocol, "http" or "https", is a differentiating factor. For example, "http://developpeur-freelance.io/" and "https://developpeur-freelance.io/" are two different addresses, although in the past there was some tolerance.

The domain name

The domain is something unique: "https://developpeur-freelance.io/" and "https://fromages-freres-marchand.fr/" are two totally different URLs pointing to different sites.

The slash after the domain

This one doesn't count, because if your link points to "https://developpeur-freelance.io" or "https://developpeur-freelance.io/", it's the same thing.

The slash at the end of the URL

Ah, this is the one we're interested in.

If the file at the end of the URL has an extension
In the case of an address ending with a file extension, for example "https://example.com/a-propos.html", you should never put a slash at the end of this type of address.

If the file has no extension
In this case, we'd imagine "https://example.com/blog", for example.
As I said before, in the past it counted, but today it doesn't. You just have to be careful not to create duplicate content, as "https://developpeur-freelance.io/blog/" is not the same address as "https://developpeur-freelance.io/blog" if the server returns the same content on both URLs then it will count as duplicate content.

On this site, I've chosen to put the slash at the end of all URLs.In the old days, when you entered a URL without a trailing slash, Firefox would automatically add it when you validated the address by pressing enter, so to avoid bugs with this browser I chose to add it.
Finally, to avoid any duplication problems, if you try to visit "https://developpeur-freelance.io/blog", the server will automatically redirect you to "https://developpeur-freelance.io/blog/". This allows the address to be supported without the slash, while avoiding the creation of duplicate content. Also, if you're a fast typist and enter "https://developpeur-freelance.io/blog//", the server will automatically remove the extra slash.

I'd say that you should also remain consistent throughout the site (this remains a personal opinion), whether or not you choose to use a slash at the end of URLs. Do the same throughout the site.

Conclusion

The slash at the end of a URL isn't really a question of SEO, it's purely and simply how the Internet and its protocols work. Search engines simply respect this protocol.