All projects

Strapi · Developer Tooling

Auto Slug

A Strapi v5 custom field that writes the slug as you type and keeps it unique.

Open Source 2025 Creator & Maintainer
Content-Type Builder · Advanced settings
The Strapi Content-Type Builder dialog for adding an Auto Slug field, on the Advanced Settings tab, showing four auto-generation checkboxes and a required-field toggle.
The rules that decide when not to regenerate. Auto-generate on creation, stop after a manual edit, preserve on edit, and backfill empty slugs are all per field, because a blog post and a landing page want different answers.

Overview

What it is

Auto Slug adds a custom field type to Strapi v5. The field knows which text field it derives from, generates in the admin panel as you type, and enforces uniqueness on write.

The interesting part is not turning a title into a slug. That is twenty lines. The interesting part is deciding when to stop doing it, which is why five of the settings are about when not to regenerate.

Motivation

Why I built it

I wrote the same lifecycle hook for the third time, slightly differently each time, and decided to package it instead of writing it a fourth.

The specific thing that pushed me over was the split between the admin panel and the API. A hook written for the admin does not run when an entry arrives over REST, so slugs go quietly missing, and I had been patching that per project.

Decisions

How it works

01

A custom field rather than a lifecycle hook

A custom field travels with the content type and is configured in the Content-Type Builder. A hook sits in project code where the next developer has to know it exists. This was the whole reason to build it as a plugin rather than paste a snippet.

02

Five settings, all about when not to regenerate

Generate on creation, stop after a manual edit, preserve on edit, backfill empty slugs, and require a value. A blog post and a landing page want different answers, so these are per field rather than per project.

03

The same slugifier on both sides

Normalize Unicode and strip diacritics, lowercase, spaces and underscores to hyphens, drop everything else, collapse repeats, trim the ends. Admin and server run identical rules, and tests cover them, because two implementations of this will disagree eventually.

Friction

What was hard

Knowing when the editor has taken over

Once somebody hand-edits a slug, regenerating from the title silently destroys their work. Tracking that handover per entry, and getting it to survive a page reload, was more fiddly than the slug logic itself.

An existing entry is not a new entry

A published entry must keep its slug, because links depend on it. An entry with an empty slug should behave like a new one. Most of the admin-side code is separating those two cases.

The state of it

Where it stands

The limitations, in plain terms. Every project here is something I built and use, not something I am selling.

Stack

Strapi v5 React Node.js Strapi Design System Jest

It is a small plugin that does one thing. In the Content Manager it looks like an ordinary text field that fills itself in, which is the point.

It targets Strapi v5 only. I have no plans to support v4.

Uniqueness is checked with a query and then a write, so a genuinely concurrent create could still collide. In a CMS admin that has not happened to me, but it is not airtight.

I maintain it because I use it. Issues get looked at when I have time, not on any schedule.

Next project

Gallery