πŸ“š General & Other

Slug Generation, Transliteration, and Collisions

Lowercase, replace non-alphanumerics with hyphens, collapse runs, trim the ends. That covers English. Everything else needs decisions.

Lowercase, replace non-alphanumerics with hyphens, collapse runs, trim the ends. That covers English. Everything else needs decisions.

Transliteration is language-specific

German ü transliterates to ue in German convention and u under a generic Unicode fold. ß becomes ss. Getting this wrong produces slugs that native speakers read as misspelled. Normalising to NFD and stripping combining marks handles accents mechanically but applies no language knowledge.

Non-Latin scripts have no good default

Stripping non-ASCII from a Chinese or Arabic title leaves an empty slug. Options are percent-encoding the native text, which is valid and displays correctly in modern browsers, or requiring a manual slug. Silently producing an empty string is the one unacceptable outcome, and it is what naive implementations do.

Collisions need deterministic handling

Two different titles can generate the same slug. Append a numeric suffix, and make the check happen at generation time β€” discovering the collision at insert time, after a unique constraint fires, means handling it in an error path where the retry logic is usually wrong.

Try it: Generate URL Slugs on SeoWolf's Notepad.