decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Slug saved on disk does not respect the confuguration setting

Open andreamoro opened this issue 3 years ago • 1 comments

Describe the bug The slug is formed after the Title property despite the config.yml suggest to use something different. I've tried to implement the identifier_field: true in the slug property in an attempt to change the situation without success.

To Reproduce I've created a brand new GitHub repo, connected to NetLify and setup a minimal config.yml as per the below.

Expected behavior I was expecting the slug to be created as per my rule, so

  • Date (respected)
  • Slug (from my field)
  • Lang (respected)

I was also expecting the slug in the markdown to be formatted the same, so with the dashes replacing the empty spaces. At this stage I'm not sure whether the slug node has been parsed.

CMS configuration

slug:
  encoding: "ascii"
  clean_accents: true
  sanitize_replacement: "-"
  
collections:
  - name: 'blog'
    label: 'Blog'
    folder: '_posts/'
    create: true
    extension: markdown
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}-{{lang}}'
    editor:
      preview: false
    fields:
      - { label: 'Lang', name: 'lang', widget: 'select', options: ["en", "it"], default: "en" }
      - { label: 'Permalink', name: 'slug', widget: 'string', identifier_field: true }
      - { label: 'Title', name: 'title', widget: 'string' }

Screenshots

image The image clearly shows the title has been used.

image Above you can see the lang has been appended, meaning that somehow the slug field in the collection is parsed.

Applicable Versions: netlify-cms-app 2.15.69 index.js:25:12 netlify-cms-core 2.54.8 bootstrap.js:85:12 netlify-cms 2.10.189

  • Git provider: GitHub
  • OS: Ubuntu
  • Browser version: Firefox 98

andreamoro avatar Mar 21 '22 06:03 andreamoro

You might use : slug: '{{year}}-{{month}}-{{day}}-{{fields.slug}}-{{lang}}'

See Configurations options

djacquel avatar Feb 12 '25 13:02 djacquel