Skip to content
Technology·1 min read·

Slug generator

Turn a title into a lowercase URL slug by stripping accents and replacing spaces and punctuation with hyphens.

The answer

The slug is lowercase. Accents are removed. Any run of characters that are not letters or numbers becomes a single hyphen, and hyphens at the ends are dropped.

Result

Slug

cafe-au-lait

What do you want to do next?

How this works

Letters are stripped of accents first, so “café” becomes “cafe”. The result is then lowercased. Everything that is not a plain letter or digit is treated as a separator.

Separators collapse. “Hello, World!” is “hello-world”, not “hello--world”. A title with no letters or digits is rejected instead of returning an empty path.

Practical steps

  1. 1

    Paste the title you want in the URL.

  2. 2

    Copy the slug into the path. Do not add spaces back in.

  3. 3

    If two titles collapse to the same slug, add a distinguishing word before you publish.

Examples

  • “Café au lait!”

    cafe-au-lait

Common mistakes

  • ×

    Leaving a trailing hyphen in a hand-edited slug after deleting the last word.

Frequently asked questions

Are numbers kept?

Yes. Digits stay in the slug. Only other symbols become hyphens.

Does this translate words?

No. It only changes letters and separators. It does not translate the title into English.

Continue reading