This tutorial was originally published on Gatemill:
With the advent of Node.js and modern application endpoint routing, I find it surprising that there is no in-built function to convert any string into an URL-optimized slug.
If your application users write content and you want to make their content searchable with an SEO-friendly URL, a slugify function is practically inevitable.
In order to turn an article’s original title “Why Uber isn’t spelled Über” into a slug optimized for URLs, parse your string through this slugify function to get “why-uber-isnt-spelled-uber”. I’ve pasted this Slugify function in a public Gist here.
Added several more special characters.
Added special characters suggested by ahmet to support the Turkish language.