Categories
Posts

Poll: Should URLs End With A Trailing Slash?

I’m curious what to know people think of these two different URL styles:

  • Trailing slash, like http://example.com/user/josephscott/
  • No trailing slash, like http://example.com/user/josephscott

The difference is very small, just a single slash. The first option includes a trailing slash, the second one does not.

Which do you prefer? Vote here:


7 replies on “Poll: Should URLs End With A Trailing Slash?”

I voted against the trailing slash, but then regretted my decision after thinking about how to interpret the text between it and what would be the second-to-last slash:

In looking at “josephscott” as a file, it would make sense to me to not have a trailing slash, because it would be the furthest that a person could go down that branch; “josephscott” would be the leaf.

In looking at “josephscott” as a directory, however, it would make sense to me to have that trailing slash, because it would (again, to me) imply that there’s more to see within that directory or “section” or “profile.” It would be possible to see something like http://www.example.com/user/josephscott/hobbies/sailing.ext or http://www.example.com/user/josephscott/to_do_list.ext

There may be some things I’m not seeing here, but having a trailing slash makes the most sense to me.

It doesn’t matter as long as you are consistent, and link and redirect to the chosen convention.

Thinking if a user was to type in the URL, they would seldomly add the trailing slash.
Which means they would get an extra redirect hop.

Also if you where to advertise on print media, you probably wouldn’t put a trailing slash

My take on this is that there should only be a trailing / if there is other navigation under the item.

Consider the following:

/company/ <- there are other sections underneath this item.
/company/about <- nothing more under the navigation structure for this item.

It’s easier for users to type or spell over the phone without the slash.

And for the user — it’s not about the directory or a file. The slash is just a separator, so there’s no need to separate username from empty space.

Run a poll on non-developers and you’ll see the majority selecting „no trailing slash”. Add an „I don’t care nor understand” and 90% will select that 🙂

Trailing slash if it’s a directory. No trailing slash if it is a filename (even one without an extension). This is what most reference sources say and indeed what I think is most logical. As you purposely did not include an extension in the question I guess it was judged on purely atheistic grounds to not have a trailing slash.

Leave a Reply

Your email address will not be published. Required fields are marked *