Slug Generator: The Rules and the Surprises
The readable part of an article URL is its slug. Paste the title and you get one, but the result still needs a quick look before you use it.
When you actually need it
Every post on a blog or documentation site needs an address, and the slug is the readable segment of it. Category pages, tag pages, and image or download file names follow the same idea: links that look written rather than generated.
In-page anchors and multilingual paths use it too. Once a title is reduced to ASCII words joined by hyphens, the link survives being pasted into chat apps and does not break on spaces or punctuation.
- Article and documentation URLs
- Category, tag, and file names
- In-page anchors and language paths
What the rules do, and where they surprise
The order is: decompose accented characters and strip the diacritics, replace everything that is not a letter, digit, underscore, or Chinese character with a hyphen, trim hyphens from both ends, then lowercase. So Café becomes cafe, and hello world becomes hello-world.
Chinese characters are kept, which produces a long percent-encoded string in the address bar: it works, but it is neither pretty nor pure ASCII. Japanese kana are not kept and become hyphens, so a title written only in kana can reduce to an empty string; Korean behaves the same way. Underscores count as word characters and survive unchanged.
- Accents are stripped, not transliterated
- Chinese is kept; kana becomes hyphens
- Underscores are not converted
What to check before publishing
First check that something is left. A title made of punctuation, emoji, or kana alone can end up with nothing but hyphens, and you will need to supply a name by hand. Then check the length: long slugs get truncated when shared or displayed, so shorter is usually better.
Uniqueness is your job. Two posts with the same title produce the same slug, so add a date or a counter. Do not change a published slug casually, because external links and search results keep pointing at the old address. For Japanese, run the title through a transliteration tool first, then generate the slug.
FAQ
What happens to a Chinese title?
The characters are kept, and the result appears percent-encoded in the address bar. It works, but it is not pure ASCII, so copying between systems can introduce encoding problems. Use English or pinyin if that matters.
Why is the slug for a Japanese title empty?
Only letters, digits, underscores, and Chinese characters survive. Hiragana and katakana are replaced with hyphens, so a kana-only title reduces to hyphens and then to nothing. Add a readable name by hand.
Can I use the generated slug as is?
Yes, after checking three things: it is not empty, the length is reasonable, and it does not clash with an existing page. Avoid changing it later, since old links break. Test a Chinese slug on the target site first.
Related tool:Slug Generator