0

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.

Joel
  • 85
  • 1
  • 7
  • Silly question. But did you try clearing your browser cache? – ksav Mar 26 '20 at 03:45
  • I did, still no luck – Joel Mar 26 '20 at 03:56
  • are those indentations present in yaml too or only here in the code example? Just be sure the yaml do not contains extra indents at the beginning of the parent lines (the child lines should, it is ok) – gazdagergo Mar 26 '20 at 07:50
  • Is your md file pushed to the master branch? – A. van Hugten Mar 26 '20 at 08:48
  • I'm working off of a dev branch, it's being pushed to that. The body of the same md file is populating in the CMS, just not the frontmatter. The frontmatter is populating from another file, so I think the issue should either be with the yaml or md file. – Joel Mar 26 '20 at 14:07
  • @gazdagergo this is a partial yaml file, the parents of these elements are indented to the left – Joel Mar 26 '20 at 15:14

1 Answers1

0

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
---
Joel
  • 85
  • 1
  • 7