Netlify cms setup ERROR | YAML Config

Config Errors:
YAMLSyntaxError: All collection items must start at the same column at line 9, column 5:

  • name: “pages”,
    ^^^^^^^^^^^^^^…
    Check your config.yml file.

Here is my Yaml.config file

backend:
name: git-gateway

# This line should *not* be indented
media_folder: "media" # Media files will be stored in the repo under images/uploads


collections:
- name: "pages",
  label: "Junctions",
  files: 
    - label: "Homepage",
      name: "homepage",
      file: "index.html"
      fields: 
        {
          - { label: "Layout", name: "layout", widget: "hidden", default: "link.njk" }
          - { label: "Description", name: "description", widget: "text" }
          - { label: "Destination", name: "destination", widget: "text" }
        }

Hey! Try removing all the commas from your YAML (except in lists) as this would be invalid :slight_smile:

collections:
- name: "pages"
  label: "Junctions"
  files: 
    - label: "Homepage"
      name: "homepage"
      file: "index.html"
      fields: 
          - { label: "Layout", name: "layout", widget: "hidden", default: "link.njk" }
          - { label: "Description", name: "description", widget: "text" }
          - { label: "Destination", name: "destination", widget: "text" }

I removed all the commas and still received an error:

Config Errors:
YAMLSemanticError: Indicator : missing in flow map entry at line 17, column 13:

      - { label: "Layout" name: "layout" widget: "hidden" default: "link.nj…
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^…

Check your config.yml file.

Dont remove the commas from the list there. Please see my example above

Used your example and now receiving this:

Config Errors:
YAMLSemanticError: Indicator : missing in flow map entry at line 17, column 13:

      - { label: "Layout", name: "layout", widget: "hidden", default: "link…
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^…

Check your config.yml file.

Copy and paste my example, remove your brackets in the fields section that wraps around the three objects of label name widget etc?

1 Like

It worked, Thank you for your help!

No worries, sorry for being long winded! I use yaml validators online and it helps quite a lot :slight_smile:
Please mark a solution so that others can easily search for their issue.

Thanks!

1 Like

Can you please help me out?

- name: "authors"

    label: "Authors"

    folder: "content/authors/authors"

    create: true

    delete: true

    format: "yml"

    identifier_field: "name"

    media_folder: "avatars"

    public_folder: "./avatars"

    editor:

      preview: false

    fields:

      - { label: Name, name: name, widget: string }

      - { label: Bio, name: bio, widget: string }

      - { label: Featured, name: featured, widget: boolean, default: false }

      - { label: Avatar, name: avatar, widget: image }

      - { label: Social, name: social, widget: list, collapsed: false, field: { label: URL, name: url, widget: string } }

      - { label: Education, name: education, widget: list, collapsed: false, fields: 

          { 

            - label: Institution, name: institution, widget: string

            - label: Year, name: year, widget: datetime, format: "YYYY-YYYY", dateFormat: "YYYY-YYYY", timeFormat: false

            - label: Score, name: score, widget: number

          }

        }

      - { label: Courses, name: courses, widget: list, collapsed: false, fields: { label: Course, name: course, widget: string }}

Error:
Error loading the CMS configuration
Config Errors:
YAMLSyntaxError: Flow map contains an unexpected : at line 48, column 20:

        - label: Year, name: year, widget: datetime, format: "YYYY-YYYY", d…
               ^

Check your config.yml file.

Your list widget is a little off. Try this:

- label: Education
  name: education
  widget: list
  collapsed: false
  fields: 
    - {label: Institution, name: institution, widget: string}
    - {label: Year, name: year, widget: datetime, format: "YYYY-YYYY", dateFormat: "YYYY-YYYY", timeFormat: false}
    - {label: Score, name: score, widget: number}

1 Like

Worked. Thank you very much

1 Like

Hello kind and smart people :slight_smile: I’ve ended up here looking for help regarding similar trouble. So, I’ll move right to the point.

My config.yaml at some poiint looks like this:

collections:
  - name: blog
    label: Blog
    folder: content/blog
    slug: '{{year}}-{{month}}-{{day}}-{{title}}'
    create: true
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' }
      - {
          label: 'Post Tags',
          name: 'postTags',
          widget: 'select',
          multiple: true,
          min: 1,
          max: 2,
          options:
            - { label: "Chicago", value: "ORD" }
            - { label: "Paris", value: "CDG" }
            - { label: "Tokyo", value: "HND" }
      }
(and the code goes on)

The part I am having trouble is Post Tags. I’ve read on the Netlify documentation, that I can use select widget with objects as options. However when I use the exact code provided there I get an error when trying to access the CMS:

Config Errors:
YAMLSemanticError: Separator , missing in flow map at line 77, column 15:

            - { label: "Chicago", value: "ORD" },
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Check your config.yml file.

When I add the missing coma (which btw should be in a very weird place according to the error), it tellms to put it in another weird place and keeps throwing more errors. I am not sure what I’m doing wrong, as the select widget seems to be rather simple in usage.

Simplest solution is to replace objects with one array with strings (and it works, I’ve tested it) but I need to have it as objects.

Could anyone please take a look? Maybe there is something I am missing here.

Try this:

collections:
  - name: blog
    label: Blog
    folder: content/blog
    slug: '{{year}}-{{month}}-{{day}}-{{title}}'
    create: true
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' }
      - label: 'Post Tags'
        name: 'postTags'
        widget: 'select'
        multiple: true
        min: 1
        max: 2
        options:
          - { label: "Chicago", value: "ORD" }
          - { label: "Paris", value: "CDG" }
          - { label: "Tokyo", value: "HND" }

Tom, thanks for the quick answer. It did remove that error but now I get a new one:

YAMLSemanticError: Separator , missing in flow map at line 71, column 11:

          name: 'postTags'
          ^^^^

However if I add commas after label, name and widget it once again changes the error message, this time to:

YAMLSyntaxError: Flow map contains an unexpected : at line 74, column 14:

          min: 1
             ^

Which I find weird since I’d assume every : is needed in this case.

Can you post the full contents of your config.yml please?

1 Like

Hey Tom, sorry for the very late reply. After quick converstation within our company I had to actually change the widget type which also resolved my problem.

2 Likes

Hey there, @true_piotrek :wave:

Thanks so much for coming back and letting us know. Glad your problem is resolved. Happy bui

1 Like