Slug Conventions
1 min read
Slugs are used as identifiers for both articles and categories. An article slug comes from the filename (minus .md), and a category slug comes from the directory name.
Rules
A valid slug must match the following regex:
/^[a-z0-9]+(?:-[a-z0-9]+)*$/
This means:
- Lowercase letters (
a-z) and digits (0-9) only - Words separated by single hyphens
- Cannot start or end with a hyphen
- No consecutive hyphens
- No uppercase letters, spaces, or special characters
Examples
Valid slugs
| Slug | Notes |
|---|---|
getting-started | Two words, hyphen-separated |
billing | Single word |
api-v2-reference | Multiple segments |
setup123 | Letters and digits |
Invalid slugs
| Slug | Reason |
|---|---|
Getting-Started | Uppercase letters |
-leading-hyphen | Starts with a hyphen |
trailing-hyphen- | Ends with a hyphen |
double--hyphen | Consecutive hyphens |
has spaces | Contains spaces |
special_chars! | Underscores and special chars |
Why Slugs Matter
Slugs serve as URL-friendly, stable identifiers. They ensure:
- Consistent URLs -- predictable paths in the help center
- Portability -- safe to use as filenames across operating systems
- Uniqueness -- within a category, each article slug must be unique