Enhancement: An option to not add fields when creating new content #453

Closed
opened 2026-10-05 02:48:11 +02:00 by adam · 5 comments
Owner

Is your feature request related to a problem? Please describe.
Have you considered an option to contentTypes fields, to NOT add the field to Metadata automatically upon creating new content, unless a value is added afterwards or have a default value defined.

Describe the solution you'd like
Let's imagine, I wanted the option to add "aliases" (might be a Hugo thing only), and have added this as a field, but I would like that field to be added to my page/post only/if a value is added to that specific field before being added to the Metadata?

Thanks

**Is your feature request related to a problem? Please describe.** Have you considered an option to contentTypes fields, to NOT add the field to Metadata automatically upon creating new content, unless a value is added afterwards or have a default value defined. **Describe the solution you'd like** Let's imagine, I wanted the option to add "aliases" (might be a Hugo thing only), and have added this as a field, but I would like that field to be added to my page/post only/if a value is added to that specific field before being added to the Metadata? Thanks <!-- github-sync-id:1658754154 -->
adam closed this issue 2026-10-05 02:48:11 +02:00
Author
Owner

I believe this is what you are looking for @dotjesper: https://frontmatter.codes/docs/content-creation/field-conditions

I believe this is what you are looking for @dotjesper: https://frontmatter.codes/docs/content-creation/field-conditions <!-- github-comment-id:1500252724 -->
Author
Owner

Sure, I tried that. For what I can gather, I can choose to show the field within the Front Matter dashboard, based on "something". However I am able to hide the field from the Front Matter dashboard, but the field is still being added to the Metadata in the markdown file - I was looking for the other way around :) Meaning, if the field is empty, it should not add the field to the metadata, but keep it visible in the Front Matter window.
I will try to have another go - thanks.

Sure, I tried that. For what I can gather, I can choose to show the field within the Front Matter dashboard, based on "something". However I am able to hide the field from the Front Matter dashboard, but the field is still being added to the Metadata in the markdown file - I was looking for the other way around :) Meaning, if the field is empty, it should not add the field to the metadata, but keep it visible in the Front Matter window. I will try to have another go - thanks. <!-- github-comment-id:1500267213 -->
Author
Owner

Ah, ok, in that case, I misunderstood you. That is the behavior how it was in the beginning. Over time we added all the fields, and to me, it feels like a best practice to give all content the field they should need.

I can see that this could be a preference, maybe we should introduce a property on the content type to support this.

Ah, ok, in that case, I misunderstood you. That is the behavior how it was in the beginning. Over time we added all the fields, and to me, it feels like a best practice to give all content the field they should need. I can see that this could be a preference, maybe we should introduce a property on the content type to support this. <!-- github-comment-id:1500281193 -->
Author
Owner
https://github.com/estruyf/vscode-front-matter/issues/609 is related to this. <!-- github-comment-id:1644706176 -->
Author
Owner

I have added a new property on the content type: clearEmpty; if you set its value to true it will not include the empty fields on content creation or remove them when empties during editing.

{
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "previewPath": null,
      "clearEmpty": true,
      "fields": [
        ...
      ]
    }
  ]
}
I have added a new property on the content type: `clearEmpty`; if you set its value to `true` it will not include the empty fields on content creation or remove them when empties during editing. ```json { "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "previewPath": null, "clearEmpty": true, "fields": [ ... ] } ] } ``` <!-- github-comment-id:1708056139 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#453