Issue: Preview urls generated using local time zone rather than UTC #698

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

I'm using Front Matter with a Hugo blog. My permalinks include the post date, and I have the following in my FM configuration:

  "frontMatter.preview.pathName": "{{date|yyyy/MM/DD}}/",

When I try to open the preview in the editor ("Front Matter: Preview content"), the URL opened is generated using the local timezone (UTC-8 for me), rather than UTC. This causes problems when the date in UTC does not match the date in my time zone.

For example, a post with the following front-matter:

date: 2017-07-06T04:03:44.000Z
slug: foo

Will be generated by Hugo at /2017/07/06/foo; however FM will open /2017/07/05/foo when I try to preview the content.

I'm not sure this is really a bug; it's more of an inconsistency between the framework and FM. I'm wondering if there's a way to configure the timezone for FM that I haven't found.

Thanks for FM; it's really cool!

I'm using Front Matter with a Hugo blog. My permalinks include the post date, and I have the following in my FM configuration: ``` "frontMatter.preview.pathName": "{{date|yyyy/MM/DD}}/", ``` When I try to open the preview in the editor ("Front Matter: Preview content"), the URL opened is generated using the local timezone (UTC-8 for me), rather than UTC. This causes problems when the date in UTC does not match the date in my time zone. For example, a post with the following front-matter: ``` date: 2017-07-06T04:03:44.000Z slug: foo ``` Will be generated by Hugo at `/2017/07/06/foo`; however FM will open `/2017/07/05/foo` when I try to preview the content. I'm not sure this is really a bug; it's more of an inconsistency between the framework and FM. I'm wondering if there's a way to configure the timezone for FM that I haven't found. Thanks for FM; it's really cool! <!-- github-sync-id:2647831850 -->
adam closed this issue 2026-10-05 03:00:50 +02:00
Author
Owner

Thanks, @nyergler, for opening this issue. I'll see what I can do to resolve it.

Thanks, @nyergler, for opening this issue. I'll see what I can do to resolve it. <!-- github-comment-id:2472708804 -->
Author
Owner

@nyergler I have included a new setting + change to the formatting logic. With the new frontMatter.global.timezone setting, you can define the timezone in which you want to format the dates.

The default is set to utc. In your case, it should now process the date as UTC and not in your timezone.

Can you verify this in the latest beta version?

@nyergler I have included a new setting + change to the formatting logic. With the new `frontMatter.global.timezone` setting, you can define the timezone in which you want to format the dates. The default is set to `utc`. In your case, it should now process the date as UTC and not in your timezone. Can you verify this in the latest beta version? <!-- github-comment-id:2476722897 -->
Author
Owner

Thanks, @estruyf, that seems to work as expected in the beta version!

Thanks, @estruyf, that seems to work as expected in the beta version! <!-- github-comment-id:2564854065 -->
Author
Owner

Thank you for verifying @nyergler 🙏

Thank you for verifying @nyergler 🙏 <!-- github-comment-id:2565275227 -->
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#698