0

I created a new Netlify CMS website based on Jekyll and created new collections workshop and consultant

With the Netlify CMS interface, I can see, add, edit and delete the new collections, but I cannot retrieve them in the view.

--/_consultants
   name.md

--/_workshops
   title.md

config.yml

collections:
  # WORKSHOPS
  - name: "workshop" # Used in routes, ie.: /admin/collections/:slug/edit
    label: "Workshop" # Used in the UI, ie.: "New Post"
    folder: "_workshops" # The path to the folder where the documents are stored
    sort: "title:desc" # Default is title:asc
    create: true # Allow users to create new documents in this collection
    slug: "{{slug}}"
    output: true
    permalink: /wokshop/:title
    fields: # The fields each document in this collection have
      - {label: "Title", name: "title", widget: "string", tagname: "h1"}
      - label: "Consultant"
        name: "consultant"
        widget: "relation"
        collection: "consultant"
        searchFields: ["name"]
        valueField: "name"
      - {label: "Location", name: "location", widget: "string"}
      - {label: "Duration", name: "duration", widget: "string"}
      - label: "Category"
        name: "category"
        widget: "select"
        options: ["Business", "Team & Culture", "Design"]
      - {label: "Price", name: "price", widget: "string", required: false}
      - {label: "Permalink", name: "permalink", widget: "hidden"}
      - {label: "Blurb", name: "ws-blurb", widget: "string"}
      - {label: "Description", name: "ws-description", widget: "markdown"}

  # CONSULTANTS
  - name: "consultant" # Used in routes, ie.: /admin/collections/:slug/edit
    label: "Consultant" # Used in the UI, ie.: "New Post"
    folder: "_consultants" # The path to the folder where the documents are stored
    sort: "date:desc" # Default is title:asc
    create: true # Allow users to create new documents in this collection
    slug: "{{slug}}"
    identifier_field: name
    output: true
    fields: # The fields each document in this collection have
      - {label: "Permalink", name: "permalink", widget: "hidden"}
      - {label: "Name", name: "name", widget: "string", tagname: "h1"}
      - label: "Image"
        name: "image"
        widget: "image"
        # default: "/uploads/chocolate-dogecoin.jpg"
        media_library:
          config:
            multiple: false
      - {label: "Bio", name: "bio", widget: "markdown"}
      - {label: "References", name: "references", widget: "markdown"}
      - {label: "Link", name: "link", widget: "string"}
      - {label: "Workshops hosted", name: "ws-hosted", widget: "number"}

When I try to retrieve the newly created workshops and consultants I can't get it to work:

<ul>
 {% for item in site.workshops %}
  <li>
   <h2>
    {{ item.title }}
   </h2>
  </li>
 {% endfor %}
</ul>

And when I try to debug the object, it returns NULL: {{ site.workshops | jsonify }}

What confuses me the most is that I can access the collections through the admin interface, but for the last 4 hours I failed at retrieving them in the view.

What am I missing?

1 Answers1

0

I found the solution! So for anyone getting stuck at this point: the information below has to go to _config.yml and not (!) to config.yml

collections:
  workshops:
    output: true
  consultants:
    output: true
  • Yeah you're conflating Jekyll's config with Netlify CMS' config. We really should rename the cms config to something more obvious. – Shawn Erquhart Sep 05 '19 at 16:57