Non mandatory slug field not saving due to invalid format when empty

Hi everyone,
I’m experiencing a strange new behavior for a non mandatory slug field based on my item title field.
Until yesterday, I was allowed to leave the field blank for the home page by means of manual edit. Now I cannot do that anymore, even though the field is not mandatory.

Is it working like that by design from now on or is it some sort of bug?

hello @federico, welcome! :slight_smile:

Have you checked that your slug field is not maybe unique:

That would mean that you cannot have two empty slugs. If that’s not the case please share your project so that I can have a look. Either here via private messages or over https://www.datocms.com/support

Yes, already checked that. Sending you the details in the support channel

Just a quick followup for everyone. It was an error on our side that has been resolved.

@mat_jack1 You mentioned that if you set a field as Unique, you cannot have two empty slugs.

I have my slug field set as unique, but I am able to have multiple content entries that have an empty slug.

What are your thoughts on this?

Sorry @Joshua.Evenson for the delay here!

Marking the field as required would be a problem for you? Because in that case surely it will work for you. Meanwhile we’ll check if unique can do what you expect.

just to confirm, that you should add required if you want the behaviour that you expect, OK?

Marking a field as required means it cannot be blank. A blank slug is required for the homepage of a website.

For now, I did make the field Required. In my code, I detect that a page is the homepage, and override the slug field.

OK, good. Maybe you can manage the homepage separately as a “single instance model”?

That would be a good solution as well. Just trying to conserve content models. I’ll consider switching it to a single instance though. Thanks!

1 Like