Automatic slug overwrites existing pages?

create:
  title: "{{ page.city }}, {{ page.name }}"
  slug: "{{ page.name.slug }}-{{ page.city.slug }}"
  fields:
    - name
    - city

I type a name and a city in the page create modal and the page is created with the correct slug. but when I do it again, with same name and city, the page is overwritten (no warning, I just arrive in an empty blueprint and the content txt-file from before is gone) instead of adding a slug with a trailing number.

Is this normal and do I have to write my own page.create:before hook to prevent this?

Thanks a lot!

I cannot reproduce this in a Kirby 5.1.4 Starterkit.

Please indicated your Kirby version, which plugin if any you are using. And please test your case in a fresh Kirby Starterkit.

If I try the above with the same name and city, I get the error message that is to be expected:

A page with the URL appendix “jane-toronto” already exists.

Hi texnixe!

kirby 5.1.4
php 8.3.22
server “nginx/1.29.0

I tested it with a fresh starterkit.
I added the create from above to the note.yml and added city and name fields (type: text) to the blueprint. → Same thing!

But I noticed, that it is only happening, if the page is still a draft. When I set it to unlisted and try to create a page with same values, I get the error message you provided. Did you change the status to listed/unlisted before creating the new page?

And another strange thing happend: After deleting a page where I also had a files section and uploaded an image, the _draft/slug/ still existed, with a image.png and image.png.txt inside, without the template.txt file. So I did not see the page in the panel anymore, but when I tried to create a page with name name/city values, I got an error that a page with the URL appendix already exists. Is there a case, when that should happen? (sorry, thats probably another issue?!)

Oh it is happening when I create a normal page (without any create-option / automatic slug). I create a page, type in a title (slug is same). I go back and create a new page, I enter the same title and the draft is overwritten (old content lost). I tested that in different settings. I created an issue on github: Draft page duplicate check fails, overwrites existing drafts instead of throwing exception · Issue #7761 · getkirby/kirby · GitHub

You are right, my create option created a listed page, not a draft. I can reproduce the issue when creating drafts. That’s a bug.