1

Let's say I have a (frontend) website where users can register and post, just like StackExchange, which makes use of a REST API to fetch the data. So the website is located at https://www.example.com and the REST API is located at https://api.example.com.

In the REST API, I (and probably most REST API developers (see many guides about REST API naming conventions online)) prefer to use plural forms for resources (e.g. https://api.example.com/users, https://api.example.com/users/john).

But what about the frontend (the website that the users and search engines will face)? I see most websites prefer to use singular forms, at least for users, like https://www.example.com/user/john instead of https://www.example.com/users/john.

What do you think is better and is there any good reasons for this in terms of UX (and maybe SEO)?

I think using the same plural form format for the user-facing website makes it easier for use as a developer (for uniformity reasons), but on the other hand, URLs like https://www.example.com/user/john seem more common to me and more user-friendly than https://www.example.com/users/john.

All discussions I could find on this topic are only considering REST API naming specifically or only focusing on websites such as blogs and e-commerce websites with multiple categories.

What are your thoughts on this?

1 Answer 1

0

Strictly speaking, your URLs are resource locators and all the browser does is performing GET on your resources (ok, sometimes POST too). So, it pretty much works the same as your API does (presumably, complying with OpenAPI standard).

I don't see any reasons, why the logic should be any different here.

Moreover, it's usually a good idea to make sure that the hierarchy of your URLs serves as a kind of breadcrumbs for the user's current location. Believe it or not, there are some power users that actually would attempt to modify their URL from https://www.example.com/users/john to https://www.example.com/users/ and expect getting the list of users like that. And in this case the plural would make much more sense than singular.

When designing the "sitemap" (the navigation tree), I try to always make sure that all the URLs in the hierarchy make sense and are accessible by deleting tailing parts and don't just crash when used like described above.

2
  • What if the application doesn't offer a list of users, e.g. for privacy and security reasons, but still offers example.com/users/username links for individual users?
    – kataba
    Jan 27 at 22:35
  • There’s multiple options. You either show them a page that says “sorry, you can’t see the list because you have insufficient permissions”, or show them a 404, or redirect them to safety, showing a notification. Really depends on the conditions
    – exp
    Jan 27 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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