I would like to create a page upon registration on my site based on user name, e.g. http://example.com/john-doe

My concern is though it’s need to be unique in the most user-friendly way. E.g. you could add john-doe-2 but it’s not cool for second John Doe (“why am I second?”).

How can I make sure it’s unique? I’d still want to have name in URL. Should I add a random number? How small should it be?

Is there a better way?

  • 1
    I think facebook does that, they put <yourname>/<yourprofileid> from memory, it has been a long time since I went there.
    – Walfrat
    Nov 9, 2017 at 13:15
  • If you're using a username (the one that's used for log-in), it should be guaranteed that they're unique. Then I don't see an issue with displaying the username in the url.
    – Jaroslav M
    Nov 9, 2017 at 14:49
  • @JaroslavM I’m using an email though
    – Runnick
    Nov 9, 2017 at 15:12
  • 2
    @Walfrat Yep, this is what you're talking about, and I think it's a perfect solution for something like this. Users try to pick a name for their URL, and if it's taken, they can try another one. Nov 9, 2017 at 19:09

3 Answers 3


I am surprised that no one has cited stackexchange's approach. The URL to my profile is: https://ux.stackexchange.com/users/28963/jamesdlin . I can choose a username, but the actual key is a unique numeric ID. My username doesn't need to be unique, and I can change it later.

Also, I will point out that if you do decide to require unique usernames, you should consider what your policies are for reaping inactive accounts. Otherwise, as your site becomes popular and as time goes by, there will be fewer and fewer available usernames, and people will end up having to add random-ish numbers to their usernames anyway (like AOL screen names in times past).


A simple way to fix this is to add a username field to the form, as suggested by dennislees.

If you need to generate a username, consider the following format:

  • First name
  • Last name
  • Number (if necessary for uniqueness)
  • Allow the user to change it afterwards

For example: JohnDoe2

There are a lot of "John Doe"s in the world, so don't expect users with common names to be upset that their auto-generated has a number. Give them an option to change the username if they don't like the auto-generated one.


Consider requesting a unique 'Display Name'

Add a field to your form, request a unique string to be used when name is displayed.

This gives the user the opportunity to provide an alternative to their name or email address to identify with, and it gives you what you need for your URLs.

When providing input for a field like that, it's a common (and therefore not really that negative) experience to see the error 'That Display Name is already in use', especially if your name is John Doe ; )

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.