Feedback: Unwanted automatic updates in the publishDate field #757

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

One feature I really love about this plugin is that it automatically updates the modification time. So I have the following configuration.

{
  "frontMatter.taxonomy.dateFormat": "yyyy-MM-dd'T'HH:mm:ss'Z'",
  "frontMatter.content.autoUpdateDate": true,
  "frontMatter.taxonomy.noPropertyValueQuotes": [
    "lastmod",
    "publishDate"
  ],
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "fields": [
        {
          "title": "Last updated",
          "name": "lastmod",
          "type": "datetime",
          "isModifiedDate": true
        },
        {
          "title": "Publish date",
          "name": "publishDate",
          "type": "datetime",
          "isPublishDate": true
        }
    }
}

And I have the front matter like this.

+++
lastmod = 2025-09-22T16:46:42Z
publishDate = 2025-09-12T10:00:00Z
title = "bio stat"
+++

But after saving the md file, there is the change.

+++
lastmod = 2025-09-22T16:57:01Z
publishDate = 2025-09-12T10:00:00.000Z
title = "bio stat"
+++

The update on the publishDate is something I don't need, and I can't find a way to turn it off.

One feature I really love about this plugin is that it automatically updates the modification time. So I have the following configuration. ``` { "frontMatter.taxonomy.dateFormat": "yyyy-MM-dd'T'HH:mm:ss'Z'", "frontMatter.content.autoUpdateDate": true, "frontMatter.taxonomy.noPropertyValueQuotes": [ "lastmod", "publishDate" ], "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "fields": [ { "title": "Last updated", "name": "lastmod", "type": "datetime", "isModifiedDate": true }, { "title": "Publish date", "name": "publishDate", "type": "datetime", "isPublishDate": true } } } ``` And I have the front matter like this. ``` +++ lastmod = 2025-09-22T16:46:42Z publishDate = 2025-09-12T10:00:00Z title = "bio stat" +++ ``` But after saving the md file, there is the change. ``` +++ lastmod = 2025-09-22T16:57:01Z publishDate = 2025-09-12T10:00:00.000Z title = "bio stat" +++ ``` The update on the `publishDate` is something I don't need, and I can't find a way to turn it off. <!-- github-sync-id:3441889832 -->
adam closed this issue 2026-10-05 03:04:05 +02:00
Author
Owner

The update to the publishDate corrects the actual time format. If I am not missing anything, it adds a 0 for the millisecond part of the timestamp, which is a correct format. The time itself is not updated, right?

There is (and I did not test this) a way to "fix" this: add a custom content type for the folder where these files are located and configure the date field format for publishDate in that configuration (without config it uses the ISO format (which has three digits at the end)).

What happens is that the underlying yaml library reads in the frontmatter, then changes something based on your settings (update lastmod) and then writes the full frontmatter object back. This might influence the order of things. It will remove comments and empty lines in my experience. And it will fix smaller compatibility issues like the format of datetime entries.

Updating the frontmatter is NOT done via string replacement in the file, but reading the complete frontmatter into an object and then modifying it.

If you want to dive deeper, have a look at frontmatter/extensibility which can be used in scripts and has a frontmatter manipulation method.

The update to the publishDate corrects the actual time format. If I am not missing anything, it adds a 0 for the millisecond part of the timestamp, which is a correct format. The time itself is not updated, right? There is (and I did not test this) a way to "fix" this: add a custom content type for the folder where these files are located and configure the [date field format](https://frontmatter.codes/docs/content-creation/fields#datetime) for `publishDate` in that configuration (without config it uses the ISO format (which has three digits at the end)). What happens is that the underlying yaml library reads in the frontmatter, then changes something based on your settings (update `lastmod`) and then writes the full frontmatter object back. This might influence the order of things. It will remove comments and empty lines in my experience. And it will fix smaller compatibility issues like the format of datetime entries. Updating the frontmatter is NOT done via string replacement in the file, but reading the complete frontmatter into an object and then modifying it. If you want to dive deeper, have a look at [frontmatter/extensibility](https://github.com/FrontMatter/extensibility) which can be used in scripts and has a frontmatter manipulation method. <!-- github-comment-id:3321787061 -->
Author
Owner

After repeated testing, I've concluded that "frontMatter.content.autoUpdateDate": true, respects the dateFormat of ModifiedDate but ignores the dateFormat of PublishDate. I believe this is a minor bug that needs fixing.

After repeated testing, I've concluded that `"frontMatter.content.autoUpdateDate": true`, respects the `dateFormat` of **ModifiedDate** but ignores the `dateFormat` of **PublishDate**. I believe this is a minor bug that needs fixing. <!-- github-comment-id:3326035456 -->
Author
Owner

A beta release is being published with a fix for unwanted date field updates in TOML. I hope this fixes your issue @toxin98

A beta release is being published with a fix for unwanted date field updates in TOML. I hope this fixes your issue @toxin98 <!-- github-comment-id:4060293100 -->
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#757