decap-cms: Hidden widget fails to show up in front matter (Hugo)

Describe the bug Using Hugo (specifically Victor Hugo), when setting a hidden widget, the key-value combination doesn’t appear in the front matter of the generated document.

To Reproduce I haven’t thoroughly tested the exact conditions. However, this is what I did:

  1. Use “deploy to netlify” in the netlify cms docs (i.e. use the Victor Hugo template)
  2. Add a hidden widget to the fields of one of the existing pages or create a new page with a hidden widget (i.e. in config.yml).
  3. Edit the page (file collection) or create a new post (folder collection) in the netlify cms UI

In my case the problem manifested in both folder and file collections and in both new files created via the UI and old files edited in the UI.

Expected behavior The hidden widget should manifest in the front matter as a key-value combination. For example, when I have - {label: "Layout", name: "layout", widget: "hidden", default: "about"}, layout: about should appear in the front matter of that file.

Applicable Versions:

  • Netlify CMS version: 2.9.1
  • Git provider: GitHub
  • OS: Windows 10
  • Browser version: Firefox 66.0.3
  • Node.JS version: 4.1.2

CMS configuration You can find it here: https://github.com/jonas-sk/pine-maastricht/blob/master/site/static/admin/config.yml. The problem specifically shows up in posts, projects, and conference-2019

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 2
  • Comments: 15 (13 by maintainers)

Most upvoted comments

Agreed, a loaded entry should have empty required fields populated with default values, always.

A default value can only ever apply when creating a new entry. If you load an existing entry, it has to be loaded as-is, otherwise fields intentionally left blank would keep being populated with default values every time you edit the file.

File collection entries can’t be created - they’re one-offs and must already exist in your repo, so the concept of defaults simply doesn’t apply. That said, if you want to open a PR to add a note about this in our docs, please do!

I have the same issue as well, but in combo with Gatsby. Can someone take a look at this? This issue is already a couple of months old.