YAMLSyntaxError: All collection items must start at the same column at line X column X
Asked Answered
Z

1

18

Im getting this error when trying to run netlify CMS.

Error loading the CMS configuration
Config Errors:
YAMLSyntaxError: All collection items must start at the same column at line 71, column 5:

  - name: 'data'
    ^^^^^^^^^^^^…
Check your config.yml file.

This is my config.yml file. Everythin else works fine but when trying to access the admin im thrown that error. I checked the identation and everything seems fine to me. Checked line 51 but couldnt findwhat the syntax error is.

---
---

collections:

  - name: 'blog'
    label: 'Posts'
    folder: '_posts'
    create: true
    slug: '{{"{{year"}}}}-{{"{{month"}}}}-{{"{{day"}}}}-{{"{{slug"}}}}'
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Date', name: 'date', widget: 'date', format: 'YYYY-MM-DD' }
      - { label: 'Description', name: 'description', widget: 'string' }
      - { label: 'Author', name: 'author', widget: 'string' }
      - { label: 'Excerpt', name: 'excerpt', widget: 'string' }
      - { label: 'Image', name: 'image', widget: 'image' }
      - { label: 'Thumbnail', name: 'thumbnail', widget: 'image' }
      - {
          label: 'Image credit',
          name: 'imageCredit',
          widget: 'string',
          required: false,
        }
      - { label: 'Type', name: 'type', widget: 'hidden', default: 'article' }
      - { label: 'Keywords', name: 'keywords', widget: 'string' }
      - { label: 'Tags', name: 'tags', widget: 'string' }
      - { label: 'Hidden', name: 'hidden', widget: 'boolean', default: false }
      - { label: 'Body', name: 'body', widget: 'markdown' }

  - name: 'job_openings'
    label: 'Job Openings'
    folder: '_job_openings'
    create: true
    slug: '{{"{{year"}}}}-{{"{{month"}}}}-{{"{{day"}}}}-{{"{{slug"}}}}'
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'job-opening' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Location', name: 'location', widget: 'string', default: 'Remote' }
      - {
          label: 'Time',
          name: 'time',
          widget: 'select',
          options: ['Full Time', 'Half-Time / Hourly'],
        }
      - { label: 'Description', name: 'description', widget: 'text' }
      - { label: 'Salary range', name: 'salaryRange', widget: 'string', required: false }
      - label: 'Responsibilities'
        name: 'responsibilities'
        widget: 'list'
        field: {label: 'Responsibility', name: 'responsibility', widget: 'string'}
      - label: 'Requirements'
        name: 'requirements'
        widget: 'list'
        field: {label: 'Requirement', name: 'requirement', widget: 'string'}
      - { label: 'Hidden', name: 'hidden', widget: 'boolean', default: false }
  

  - name: 'data'
    label: 'Data'
    editor:
      preview: false
    files:
      - name: 'departments'
        label: 'Departments'
        file: '_data/departments.json'
        fields:
          - name: 'data'
            label: 'Departments'
            widget: 'list'
            fields:
              - { label: 'Name', name: 'name', widget: 'string' }
              - {
                  label: 'Avatar',
                  name: 'avatar',
                  widget: 'image',
                  required: false,
                }
      
      -name: 'career-pathways'          
        label: 'Pathways'
        file: '_data/career-pathways.json'
        fields:
          -name: 'data'
            label: 'Guilds'
            widget: 'list'
            fields:
              - { label: 'Name', name: 'name', widget: 'string' }
              -name: 'levels'
                label: 'Levels'
                widget: 'list'
                fields:
                  - { label: 'Title', name: 'title', widget: 'string' }
                  - { label: 'Type', name: 'type', widget: 'string' }

Again, everything works fine. I can access the collections as well. Dont really know what may be causing this.

Zandrazandt answered 26/2, 2021 at 0:3 Comment(3)
change -name: to - name:Rader
You fixed the issue which the question was asking about with your edit. That is not helpful to those looking for how to resolve the issue. @RaderOutofdoors
I never made an edit. I might be overlooking something, but of the edits that were made by others, I don't see any that hide the issue with a fix - every version has a missing space in three occurrences of -name:.Rader
C
13

Like Ross mentioned in the comment, you have three times -name: instead of - name: in the YAML, so just add the space between - and the key name.

There are no line numbers. But the three from the bottom.

Caffrey answered 27/2, 2021 at 8:11 Comment(2)
Also check that tabs and spaces aren't mixed for indentation. This was the problem on my end.Mown
In my case there was an issue with the indentation of a parameter lower down the YAML structure. The error wasn't specific enough, so I didn't know what to look for at first.Synchronous

© 2022 - 2024 — McMap. All rights reserved.