Ability to have a section who generates only unique slugs using incremental suffixes, even if this section has no URLs for entries
This is also true with other element types (category groups w/o URLs).
This caught me by surprise – I was under the impression slugs always had to be unique (within section/group, and on the the same structure depth), which really seems the way they are useful, and how most people think of them (AFAIK).
Currently Craft only cares that the resulting URIs are unique, and only for elements that have URIs. It will increment the slug only as a way to produce a unique URI; whether the slug itself is unique or not doesn’t matter.
Craft has a maxSlugIncrement config option. If you set this to 1, Craft will not allow an entry to be saved with a duplicate slug.
@jamiewade - There is a bug with maxSlugIncrement. If you save an entry with disabled status it still generates duplicated slug.
$entry = new Entry();
$entry->enabled = false;
$entry->title = "test";
$return = Craft::$app->elements->saveElement($entry);
@bruno-canada Please can you create a new issue to report this
@jamiewade - Done. https://github.com/craftcms/cms/issues/6152
For posterity, things are currently working as expected – see https://github.com/craftcms/cms/issues/6152#issuecomment-635375476.
Most helpful comment
Craft has a
maxSlugIncrementconfig option. If you set this to1, Craft will not allow an entry to be saved with a duplicate slug.