Ghost
Ghost copied to clipboard
🎨 Improve post title-slug sync
no issue
- Before, one had to manually clear the post slug from the post settings panel, and then change the title (which triggers an auto-save), to see the title change reflected in the post slug. This is annoying and cumbersome, and may lead to unwanted post slugs, so I propose an updated implementation, which essentially keeps the post slug constantly synced with the post title except in the following 2 cases:
- The user has manually changed the slug.
- The post has already been published. ‎
- [x] There's a clear use-case for this code change, explained above
- [x] Commit message has a short title & references relevant issues
- [x] The build will pass (run
yarn test:allandyarn lint)
Before, one had to manually clear the post slug from the post settings panel, and then change the title (which triggers an auto-save), to see the title change reflected in the post slug.
The intentional behaviour here is that as long as you haven't manually set a post slug or published your post then the title+slug are kept in sync. This used to be the case but appears to have broken recently. We do not want to always sync the title+slug because that causes problems when you want to manually set a slug that is different to the title.
The intentional behaviour here is that as long as you haven't manually set a post slug or published your post the title+slug are kept in sync. This used to be the case but appears to have broken recently. We do not want to always sync the title+slug because that causes problems when you want to manually set a slug that is different to the title.
I see your point here. However, there might be users like me who might want to keep them always synced, or at least have a less cumbersome way than the current one to sync them. Can we maybe reach a compromise? For example, a small refresh-like icon button could be added next to the slug input field. This, once clicked, generates the slug from the current title and updates it. What do you think?
Also, let me add another thing: I was doing the wrong thing before - basically updating the slug on every auto-save. This is wrong and causes the problem that you mentioned - that it's not possible to manually set a slug that is different from the title, as any auto-save would sync it.
Now I've pushed a different way to do this, which only acts on title change. So the slug update is less obtrusive, as it only happens when the title is changed. It might still interfere with the user's intention though, if they want to keep a custom slug, then update the title: they would see their custom slug overwritten.
Adding a button specifically for that goes against Ghost's design ethos and over-complicates the UI.
Having the slug auto-update on title change only when it hasn't been changed manually was previously working very well and has been the case for many years without issue. Restoring that behaviour would be preferable
Ok, I understand. I didn't know about the old behaviour that you mentioned as I started using Ghost recently, so it's always been broken for me, but I can try to restore that same behaviour based on your description of it.
@kevinansfield Is right here that it's not desirable for the slug to auto-update after the post has been published. This could cause published URLs to break when a typo or formatting issue in the title is fixed.
Thanks @kevinansfield and @markstos for your comments that helped me understand how this should behave.
To recap, I updated the implementation so that post title and slug are kept synced except in the 2 cases you mentioned above:
- The user has manually changed the slug.
- The post has already been published.
Please check again and let me know if the current implementation looks good.