Issue: Draft field in custom content type does not default to value of true #309

Closed
opened 2026-10-05 02:39:22 +02:00 by adam · 3 comments
Owner

Describe the bug
When creating a new content with custom content type, draft field is populated as draft: "" unless content type has a default value of true set for the draft field.

To Reproduce
Steps to reproduce the behavior:
Here is my frontmatter.json

{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "blog",
      "pageBundle": true,
      "template": "[[workspace]]/archetypes/blog/index.md",
      "previewPath": null,
      "fields": [
        {
          "title": "Title",
          "name": "title",
          "type": "string",
          "single": true,
          "default": "{{title}}"
        },
        {
          "title": "Slug",
          "name": "slug",
          "type": "slug",
          "editable": true,
          "default": "{{slug}}"
        },
        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft"
        },
        {
          "title": "Creation date",
          "name": "date",
          "type": "datetime",
          "isPublishDate": true,
          "default": "{{now}}"
        },
        {
          "title": "Modified date",
          "name": "lastmod",
          "type": "datetime",
          "isModifiedDate": true,
          "default": "{{now}}"
        },
        {
          "title": "Description",
          "name": "description",
          "type": "string",
          "default": "&summary"
        },
        {
          "title": "Summary",
          "name": "summary",
          "type": "string",
          "default": "*summary"
        },
        {
          "title": "Keywords",
          "name": "keywords",
          "type": "list",
          "default": ""
        },
        {
          "title": "Content type",
          "name": "type",
          "type": "string",
          "default": "blog"
        },
        {
          "title": "Weight",
          "name": "weight",
          "type": "number",
          "default": 10
        },
        {
          "title": "Sub-title",
          "name": "subtitle",
          "type": "string",
          "single": false,
          "wysiwyg": true,
          "default": ""
        },
        {
          "title": "Is a Featured Post",
          "name": "featuredPost",
          "type": "boolean",
          "default": false
        },
        {
          "title": "Header Image",
          "name": "headerImage",
          "type": "fields",
          "fields": [
            {
              "title": "Image",
              "name": "src",
              "type": "image",
              "default": "images/headerdefault.png",
              "isPreviewImage": true
            },
            {
              "title": "Image title",
              "name": "title",
              "type": "string",
              "single": true,
              "default": ""
            },
            {
              "title": "Image Alt-Text",
              "name": "alt",
              "type": "string",
              "single": true,
              "default": ""
            }
          ]
        },
        {
          "title": "Categories",
          "name": "categories",
          "type": "categories"
        },
        {
          "title": "Tags",
          "name": "tags",
          "type": "tags"
        }
      ]
    }
  ],
  "frontMatter.framework.id": "hugo",
  "frontMatter.content.publicFolder": "assets",
  "frontMatter.content.pageFolders": [
    {
      "title": "Pages",
      "path": "[[workspace]]/content",
      "excludeSubdir": true
    },
    {
      "title": "Blog",
      "path": "[[workspace]]/content/blog"
    },
    {
      "title": "About Page",
      "path": "[[workspace]]/content/about"
    }
  ],
  "frontMatter.dashboard.content.cardTags": "tags"
}

When draft is:

        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft"
        },

The frontmatter becomes:

draft: ""

I have to explicitly state:

        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft",
          "default": true
        },

in order to get:

draft: true

Expected behavior
Standard draft field should have default of true value on frontmatter creation.

Desktop (please complete the following information):

  • OS: Windows 10
  • VScode 1.7.0
  • Front Matter 8.0.1
**Describe the bug** When creating a new content with custom content type, draft field is populated as `draft: ""` unless content type has a default value of true set for the draft field. **To Reproduce** Steps to reproduce the behavior: Here is my frontmatter.json ```json { "$schema": "https://frontmatter.codes/frontmatter.schema.json", "frontMatter.taxonomy.contentTypes": [ { "name": "blog", "pageBundle": true, "template": "[[workspace]]/archetypes/blog/index.md", "previewPath": null, "fields": [ { "title": "Title", "name": "title", "type": "string", "single": true, "default": "{{title}}" }, { "title": "Slug", "name": "slug", "type": "slug", "editable": true, "default": "{{slug}}" }, { "title": "Is in draft", "name": "draft", "type": "draft" }, { "title": "Creation date", "name": "date", "type": "datetime", "isPublishDate": true, "default": "{{now}}" }, { "title": "Modified date", "name": "lastmod", "type": "datetime", "isModifiedDate": true, "default": "{{now}}" }, { "title": "Description", "name": "description", "type": "string", "default": "&summary" }, { "title": "Summary", "name": "summary", "type": "string", "default": "*summary" }, { "title": "Keywords", "name": "keywords", "type": "list", "default": "" }, { "title": "Content type", "name": "type", "type": "string", "default": "blog" }, { "title": "Weight", "name": "weight", "type": "number", "default": 10 }, { "title": "Sub-title", "name": "subtitle", "type": "string", "single": false, "wysiwyg": true, "default": "" }, { "title": "Is a Featured Post", "name": "featuredPost", "type": "boolean", "default": false }, { "title": "Header Image", "name": "headerImage", "type": "fields", "fields": [ { "title": "Image", "name": "src", "type": "image", "default": "images/headerdefault.png", "isPreviewImage": true }, { "title": "Image title", "name": "title", "type": "string", "single": true, "default": "" }, { "title": "Image Alt-Text", "name": "alt", "type": "string", "single": true, "default": "" } ] }, { "title": "Categories", "name": "categories", "type": "categories" }, { "title": "Tags", "name": "tags", "type": "tags" } ] } ], "frontMatter.framework.id": "hugo", "frontMatter.content.publicFolder": "assets", "frontMatter.content.pageFolders": [ { "title": "Pages", "path": "[[workspace]]/content", "excludeSubdir": true }, { "title": "Blog", "path": "[[workspace]]/content/blog" }, { "title": "About Page", "path": "[[workspace]]/content/about" } ], "frontMatter.dashboard.content.cardTags": "tags" } ``` When draft is: ```json { "title": "Is in draft", "name": "draft", "type": "draft" }, ``` The frontmatter becomes: ```yaml draft: "" ``` I have to explicitly state: ```json { "title": "Is in draft", "name": "draft", "type": "draft", "default": true }, ``` in order to get: ```yaml draft: true ``` **Expected behavior** Standard draft field should have default of `true` value on frontmatter creation. **Desktop (please complete the following information):** - OS: Windows 10 - VScode 1.7.0 - Front Matter 8.0.1 <!-- github-sync-id:1333951914 -->
adam closed this issue 2026-10-05 02:39:22 +02:00
Author
Owner

Thanks, @anakinsleftleg, for this suggestion. The draft field will now be set to true when no default value is provided.

Thanks, @anakinsleftleg, for this suggestion. The draft field will now be set to `true` when no default value is provided. <!-- github-comment-id:1212177193 -->
Author
Owner

I thought, based on the documentation, that that was already the default outcome.
https://frontmatter.codes/docs/content-creation/fields#outcome

Seems to imply that it is.

I thought, based on the documentation, that that was already the default outcome. https://frontmatter.codes/docs/content-creation/fields#outcome Seems to imply that it is. <!-- github-comment-id:1212207380 -->
Author
Owner

I'll blame the person that wrote the documentation. Oh, wait, that was me. The good thing is that it will now work as how it is documented.

I'll blame the person that wrote the documentation. Oh, wait, that was me. The good thing is that it will now work as how it is documented. <!-- github-comment-id:1212273313 -->
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#309