Gatsby - file collection field not being processed

Hello,

I’m new to Netlify cms and just trying to learn through using the docs and the official Gatsby starter: https://github.com/netlify-templates/gatsby-starter-netlify-cms/

I am running into a problem when creating a new file collection. One of the field widgets which holds the ‘templateKey’, is not being processed resulting in errors when trying to build.

- name: "menus"
  label: "Menus"
  files:
  - file: "src/pages/menus/takeaway.md"
    label: "Takeaway Menu"
    name: "takeaway"
    fields:
      - {label: "Template Key", name: "templateKey", widget: "hidden", default: "takeaway-menu"}
      - {label: Subheading, name: subheading, widget: string}

The full code snippet in question can be found here

All the other fields in this file collection show up perfectly in the cms the problem arises when trying to update the page I get this error:

error Your site’s “gatsby-node.js” created a page with a component that doesn’t exist.

The path to the missing component is “/opt/build/repo/src/templates/null.js”

The page object passed to createPage:

The path for the component template should come from the ‘templateKey’ in config.yml however null is passed since it is not given a value.

The resulting markdown file does have everything else show up in the frontmatter and adding the templateKey in manually does make the errors disappear when building but this needs to be done every time after updating the cms.

I have tested out creating new folder collections with no issues passing through the templateKey however I can’t get it to work with file collections. Any suggestions would be great!

Hi @crolla97 and welcome to the community.

The hidden widget is not supported for file collections at the moment Feat: support hidden widget in files collections · Issue #3046 · netlify/netlify-cms · GitHub

as it has a predefined unedited value and was meant to be used when creating new entries only.

You can up vote the feature request for it to get more visibility.