hello-world-你好-cafe-naive-resumeAbout Slugify String
A slug is the human-readable, SEO-friendly identifier in a URL path, like turning "My First Blog" into my-first-blog. This tool converts any title into a clean slug locally in your browser: lowercasing, replacing spaces with hyphens, stripping punctuation, optionally transliterating non-Latin scripts, collapsing repeated separators, and trimming leading or trailing hyphens. You can customize the separator, maximum length, and whether to keep Unicode characters. Transliteration decides whether non-Latin text can appear in a path and is the part needing agreement first. One common approach romanises so the path stays readable with no escaped characters, while another drops untranslatable characters for a shorter path that may lose distinctness. The two differ greatly on Chinese and Japanese content, so choose explicitly rather than accepting the tool default. Once published, a path should stay as stable as possible, the awareness this conversion most needs. After external references, search indexing and user bookmarks exist, any change breaks the old link, so keeping the original and pointing new links at it beats editing historical paths for tidiness. If a change is unavoidable, configure a redirect at the same time. Separator and edge rules must be uniform or similar content yields different paths. Runs of whitespace and punctuation become multiple separators, and without collapsing they leave a string of hyphens, while leading or trailing separators make a path look truncated. Include collapsing runs and trimming the edges in the rules, then spot-check the output. Case and maximum length are another set to fix. Forcing lowercase avoids several paths for one item and parses correctly on case-insensitive servers, while transliterating a long title directly yields an unreadable path, so set a length cap and truncate at a word boundary rather than cutting a word in half. Conflicts with existing routes must be detected during generation, not after deployment. Conversion maps different sources to one result, such as two titles differing only in punctuation, and the later one then overwrites the earlier. Check whether the result is taken and append a distinguishing suffix as part of the process rather than an exception. Finally, keeping the source-to-path mapping matters for maintenance. To investigate why a link broke or whether two paths point at one item, a queryable mapping beats re-running the rules. Record the generated result alongside the original title so a later rule change can still explain why a given path was produced.
How It Works Internally
Conversion normalizes a title into a URL-safe identifier: lowercase, spaces and punctuation replaced by hyphens, repeated hyphens collapsed and leading or trailing ones removed. The open question is what to do with non-ASCII characters — keep them (percent-encoded when shared) or transliterate — and both have costs, so the usual practice pairs them with an English keyword or a numeric suffix rather than chasing a literal match.
Hello World! 你好hello-world (the non-ASCII part is kept, transliterated or dropped by policy)Measured on This Page
| Fixed: Chinese dropped | The old rule [^a-zA-Z0-9]+ treated every non-Latin character as a separator — 你好 世界 produced an empty slug and Hello 你好 World collapsed to hello-world. On a site aimed at Chinese users that broke the most common input. Now Unicode letters/digits (\p{L}\p{N}) are kept |
|---|---|
| Multilingual | All six cases match the Python implementation: 你好-世界, 東京-タワー, привет-мир, naive-resume |
| Diacritics | Café → cafe, naïve → naive (NFD decomposition strips combining marks); with the option off, é is preserved rather than dropped |
| Separator handling | Whitespace and punctuation collapse to a single separator (never --), with leading/trailing separators trimmed |
| Length limit | A maximum length trims trailing leftover separators afterwards |
The slug trade-off is readability versus compatibility: the old ASCII-only habit (transliterate or use IDs) helps legacy systems, but modern browsers, search engines and mainstream CMSs all accept UTF-8 slugs, so keeping Chinese titles verbatim reads best and this page no longer discards non-Latin scripts. Two reminders: diacritic stripping only matters for Latin (CJK has no combining marks), and a published slug should stay stable — changing it 404s inbound links and needs a 301.
How to Use
- Open "Slugify String"
- Paste a title or a sentence into the left pane
- Set the separator, max length and lowercase option
- Toggle diacritic stripping if needed
- Copy the slug that appears on the right
Use Cases
- Blog permalinks — Turn article titles into concise slugs for permalinks that read well and rank better.
- Product URLs — Convert product names into clean paths, dropping symbols that would be percent-encoded.
- Doc anchors — Generate heading ids for Markdown that match the table of contents for in-page jumps.
- File naming — Turn titles with spaces and accents into safe strings suitable for filenames.
- i18n routing — Batch-generate localized path segments from translated titles for multilingual sites.
- Tag normalization — Convert user-submitted tags into consistent slug form for deduplication and canonical storage.
- URL migration — Re-slugify old URL paths with a new separator or length limit to prepare for a site restructuring.
FAQ
Why hyphens instead of underscores?
Google explicitly recommends hyphens to separate words in URLs; search engines treat them as spaces marking word boundaries, while underscores may join words into one token.
How are non-Latin titles handled?
You can transliterate (e.g. Chinese to pinyin) or keep original characters. Modern browsers support Unicode URLs, but kept characters get percent-encoded when shared, so the choice depends on your platform.
How long should a slug be?
Aim for 3-5 keywords under about 60 characters. Overlong slugs get truncated in results and are hard to share; set a maximum length to auto-trim.
What if two titles produce the same slug?
This tool only transforms strings; deduplication belongs in your system. A common approach is appending a counter or short hash to repeated slugs to keep URLs unique.
Does it handle emoji and symbols?
By default it removes emoji and punctuation, keeping only letters, digits, and the separator. You can adjust options to preserve specific symbols if needed.
A Chinese title becomes percent-encoded in the slug. Is that usable?
It works but not well. Keeping the characters means the link is percent-encoded when shared or pasted, becoming long and hard to dictate; converting to pinyin reads better but drifts from the meaning and collides on homophones. Pairing the Chinese title with an English keyword or a numeric suffix gives a slug that is both readable and unique without chasing a literal match.
What happens to old links after changing a slug?
You must redirect, or the old addresses break outright and indexed pages plus external references are lost. Point the old address at the new one with a permanent redirect and keep it in place long term; whether a redirect is temporary or permanent affects caching and how signals transfer, so do not substitute a temporary one. Update the sitemap afterwards to speed up discovery.
Chinese titles produce an empty slug — why?
slugify keeps Latin letters and digits by default and strips CJK entirely. For Chinese content you need transliteration (pinyin) or to keep the original text URL-encoded. Pure-pinyin slugs and encoded Chinese both have SEO trade-offs — pick a strategy before batch processing.