A powerful Directus extension that automatically generates URL-friendly slugs from other fields in your collection. Perfect for creating SEO-friendly URLs, blog posts, articles, and any content that needs clean, readable URLs.
npm install directus-slug-generator- Copy the extension to your Directus extensions directory
- Install dependencies:
npm install - Build the extension:
npm run build - Restart Directus
- Configure the interface in your collection fields
# Install the latest version
npm install directus-slug-generator
# Clone or download the extension
git clone https://github.com/markosiilak/directus-slug-generator.git
cd directus-slug-generator
# Install dependencies
npm install
# Build the extension
npm run build
# Copy to your Directus extensions directory
cp -r . /path/to/your/directus/extensions/interfaces/slug-generator/- Download the latest release from GitHub Releases
- Extract to your Directus extensions directory
- Install dependencies and build
- Go to your Directus admin panel
- Navigate to Settings โ Data Model
- Select your collection (e.g., "Articles")
- Add a new field (e.g., "slug")
- Set the interface to "Slug Generator"
{
"select_field": "title",
"generation_mode": "slug", // "slug" | "uuid"
"auto": true, // Auto-generate on mount/changes
"required": true,
"separator": "-",
"lowercase": true,
"placeholder": "Enter a slug or url...",
"custom_empty_message": null,
"custom_format_message": null,
"custom_unique_message": null,
"allow_duplicates": false, // If false, checks uniqueness in the collection
"auto_update_mode": "change", // "disabled" | "change" | "blur" | "focus" | "realtime"
"preserve_existing": false, // Keep existing value when source changes
"update_delay": 100,
"show_preview_link": true,
"preview_base_url": "https://example.com",
"preview_open_in_new_tab": true
}- ๐ Automatic generation from any source field
- ๐ UUID mode: generate RFC4122 v4 values when desired
- โก Auto-update with multiple trigger modes
- ๐พ Preserve existing value on source changes
- ๐ Preview link rendering with configurable base URL and target
- ๐ Date awareness when the source is a date-like field
- ๐ Transliteration for Cyrillic, German/Nordic, and broader Latin characters
- โ Validation for URL/slug format and optional uniqueness check
// Collection: blog_posts
// Fields: title, slug, content, published_date
{
"select_field": "title",
"auto": true,
"auto_update_mode": "change",
"separator": "-",
"lowercase": true
}
// Input: "My Amazing Blog Post!"
// Output: "my-amazing-blog-post"{
"generation_mode": "uuid",
"auto": true,
"allow_duplicates": true
}{
"show_preview_link": true,
"preview_base_url": "https://example.com/blog",
"preview_open_in_new_tab": true
}// Collection: products
// Fields: name, slug, category, price
{
"source_field": "name",
"auto_update": true,
"update_mode": "change",
"separator": "-",
"lowercase": true,
"preserve_existing": true
}
// Input: "iPhone 15 Pro Max"
// Output: "iphone-15-pro-max"| Mode | Description |
|---|---|
disabled |
No automatic updates |
change |
Update on input/change events |
blur |
Update when source field loses focus |
focus |
Update when source field gains focus |
realtime |
Same as change (live typing) |
See the JSON block above for all available options and defaults.
Built-in transliteration covers:
- Cyrillic (Russian)
- German/Nordic (รคโae, รถโoe, รผโue, รโss, รฅโa, รฆโae, รธโo)
- Broad Latin accents (รก, รง, รฑ, etc.)
{
"transliteration": {
"custom_rules": {
"&": "and",
"ยฉ": "copyright",
"ยฎ": "registered"
}
}
}- Format: Accepts full URLs (http/https) or slugs. For URLs, dots/colons/slashes are preserved and cleaned. For slugs, letters, numbers, hyphens and slashes are allowed and normalized.
- Uniqueness: If
allow_duplicatesis false, the value is checked for uniqueness in the current collection (excluding the current item by primary key). - Draft bypass: If your item status is
draft, validation is skipped until publishing.
# Clone the repository
git clone https://github.com/markosiilak/directus-slug-generator.git
cd directus-slug-generator
# Install dependencies
npm install
# Build for development
npm run build
# Watch for changes
npm run dev
# Run tests
npm test# Build optimized version
npm run build
# Build with source maps
npm run build:dev| Event | Payload |
|---|---|
input |
string (the current value) |
validation |
boolean (is valid) |
- Built for Directus
- Inspired by modern URL practices
- Thanks to the Directus community for feedback and contributions
Made with โค๏ธ by Marko Siilak