Joel
Joel

Reputation: 85

Netlify CMS widgets not populating

Summarize the problem

I'm setting up Netlify CMS with a Gatsby site, using markdown files for content. After adding widgets to the config.yml file, content that should be pulled in from the frontmatter of the file into those widgets isn't showing up (the widgets themselves are there, but empty). The body of the document, however, does show up in the markdown widget.

Describe what you've tried

I've reformatted the .yml doc, copy/pasted from lines that are working correctly, etc.

Show some code

.md file:

---
title: location
sun: Closed
mon-tue: 10AM - 7PM
wed-thu: 10AM - 8PM
fri: 9AM - 8PM
sat: 9AM - 5PM
---

## Address

xxxx xxxxxxxx xxx.  
xxxx, xxxx xxxxx  
[(xxx) xxx-xxxx](tel:(xxx) xxx-xxxx)

.yml:

      - file: "/src/markdown-pages/location.md"
        label: "Location"  
        name: "location"
        widget: "object"
        fields:
          - {label: "Address", name: "body", widget: "markdown"}
          - label: "Hours"
            name: "hours"
            widget: "object"
            fields:
              - {label: "Sunday", name: "sun", widget: "string"}
              - {label: "Mon-Tues", name: "mon-tue", widget: "string"}
              - {label: "Wed-Thurs", name: "wed-thu", widget: "string"}
              - {label: "Friday", name: "fri", widget: "string"}
              - {label: "Saturday", name: "sat", widget: "string"}

Screen shot of CMS

Edit

Adding additional context that I just realized may be relevant: I'm working in a dev branch that's being pushed to a subdomain via Netlify (dev.mysite.com). This is a new branch - and the fields in question were added after I started working from this branch. The fields added when I was working in the master branch are working. I haven't tried merging yet, but will do so - but I'd still like to know if this could be the issue, and why updates wouldn't show up in the dev branch.

Upvotes: 0

Views: 311

Answers (1)

Joel
Joel

Reputation: 85

Got it - I needed to nest the frontmatter in the .md file to mirror the yaml file:

---
title: location
hours:
  sun: Closed
  mon-tue: 10AM - 7PM
  wed-thu: 10AM - 8PM
  fri: 9AM - 8PM
  sat: 9AM - 5PM
---

Upvotes: 0

Related Questions