We've switched over to using Hashids for our URL slugs on CodePen. You might notice that the slugs you get when you save a Post or Pen are 6 characters long now instead of 5.

It's a neat system for us because:

  • Our old system required plucking a new one off a database table. It was clever but this is cleaner and it's nice to not have to hit the db for one.
  • The slugs still appear random. It's best this way, so it's not terribly easy to write a scraping script or something that just enumerates through content.
  • It prevents swear words from randomly coming up.
  • We can still make it letters only, which we think just looks nicer.
  • We removed lowercase i's and l's from the slugs, just because they can be hard to differentiate quickly.
  • It doesn't depend on anything but cool math
  • It'll basically last us forever, or if not, we just move to 7 characters then it really will.