payload icon indicating copy to clipboard operation
payload copied to clipboard

Auto-slug generation broken in website template

Open ali-issa opened this issue 1 year ago • 3 comments

Describe the Bug

The slug field doesn't auto-generate from the title when creating new pages in the website template. Users must manually click on the generate button instead of having them automatically generated from page titles.

Might be related to #12956

https://github.com/payloadcms/payload/blob/537f58b4bc4e079add8267c1f900cd535f344af7/templates/website/src/fields/slug/SlugComponent.tsx#L30

getDataByPath may not be returning the current value reliably, or there could be timing issues with when the form data is available.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload

Reproduction Steps

  1. Run pnpm create-payload-app@latest and select the website template
  2. Open the admin dashboard and go to Pages
  3. Create a new page and enter a title
  4. The slug field remains empty instead of auto-generating

Which area(s) are affected? (Select all that apply)

area: templates

Environment Info

Binaries:
  Node: 23.10.0
  npm: 11.3.0
  Yarn: 1.22.22
  pnpm: 10.15.1
Relevant Packages:
  payload: 3.58.0
  next: 15.4.4
  @payloadcms/email-nodemailer: 3.58.0
  @payloadcms/graphql: 3.58.0
  @payloadcms/live-preview: 3.58.0
  @payloadcms/live-preview-react: 3.58.0
  @payloadcms/next/utilities: 3.58.0
  @payloadcms/payload-cloud: 3.58.0
  @payloadcms/plugin-form-builder: 3.58.0
  @payloadcms/plugin-nested-docs: 3.58.0
  @payloadcms/plugin-redirects: 3.58.0
  @payloadcms/plugin-search: 3.58.0
  @payloadcms/plugin-seo: 3.58.0
  @payloadcms/richtext-lexical: 3.58.0
  @payloadcms/translations: 3.58.0
  @payloadcms/ui/shared: 3.58.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12

ali-issa avatar Oct 02 '25 14:10 ali-issa

@ali-issa If it helps, here's my complete slug field implementation: https://gist.github.com/notflip/9794477c2ff88de618a61683c06a06f2 (live slug update when editing title, if the doc doesn't exist yet, and checking uniqueness during typing).

notflip avatar Oct 04 '25 03:10 notflip

This has been fixed with the release of our new slug field in https://github.com/payloadcms/payload/pull/14007

It's been added to the templates by default but you can now import it into your project as well from the payload package

paulpopus avatar Oct 08 '25 14:10 paulpopus

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Oct 16 '25 05:10 github-actions[bot]