Regular expressions and text guides
URL slugs: handle collisions after normalization
Generate readable slugs while retaining stable identifiers and detecting collisions from accents or punctuation.
Inspect the normalization rule
Nav Tools decomposes text with NFKD, removes combining marks, lowercases and replaces nonletter/nonnumber runs with hyphens.
Different source titles can therefore produce the same slug. Use the generator for readability, not uniqueness.
Café Guide → cafe-guide
Cafe Guide → cafe-guideKeep an independent stable identity
A title can change while the published URL should remain stable. Store a record identifier independently from its display slug.
At creation, check the slug against existing routes and resolve collisions using a documented suffix policy.
Unicode slugs still need URL encoding
The generator preserves Unicode letters and numbers. A Chinese title can remain Chinese rather than becoming Latin transliteration.
Encode the slug as a path segment when building an actual URL. Do not percent-encode the whole URL including its separators.
标题 工具 → 标题-工具
encodeURIComponent('标题-工具') → %E6%A0%87%E9%A2%98-%E5%B7%A5%E5%85%B7Preserve old links after editorial changes
Regenerating all slugs after a title cleanup can break incoming links and duplicate indexed pages.
Keep existing published slugs; if a move is necessary, implement a meaningful permanent redirect and update internal links. A generator does not handle route migration.