Slug is null with Netlify CMS and Gatsby

I’m trying to get Netlify CMS setup, and running into issues when I use it to create new markdown files. I tried to read through the docs to get it configured correctly but something doesn’t seem to be adding up. Part of the issue seems to come from the fact that I have my own slug field that I use, and the docs say I can use fields.slug to get around conflicts, but it still puts in null when I try to use it.

Relevant parts of config.yml

  - name: "staff"
    label: "Staff Members"
    label_singular: "Staff Member"
    summary: "{{firstName}} {{lastName}}"
    folder: "content/staff"
    create: true
    slug: "{{fields.slug}}"
    media_folder: ""
    public_folder: ""
    path: "{{fields.slug}}"
    sortable_fields: [""]
      preview: true
      - { label: "Type", name: "type", widget: "string" }
      - {
          label: "Slug",
          name: "slug",
          widget: "string",
              "A slug can have no spaces or special characters",
          required: true,
      - { label: "First Name", name: "firstName", widget: "string" }
      - { label: "Last Name", name: "lastName", widget: "string" }
      - { label: "Email", name: "email", widget: "string" }
      - { label: "Body", name: "body", widget: "markdown" }

What the markdown should look like:

type: "staff"
slug: "kyager"
firstName: "John"
lastName: "Doe"
email: "[email protected]"

I do stuff.

What I get from Netlify CMS:

type: staff
slug: hello
firstName: Hello
lastName: World
email: [email protected]

I do stuff.

The filename ends up being .md, just the extension, no filename

Source: JavaSript – Stack Overflow

November 27, 2021
Category : News
Tags: gatsby | javascript | netlify | netlify-cms

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.