Skip to content

add creation-date-key modification-date-key configuration options#531

Open
BennoLossin wants to merge 7 commits intozk-org:mainfrom
BennoLossin:frontmatter-config
Open

add creation-date-key modification-date-key configuration options#531
BennoLossin wants to merge 7 commits intozk-org:mainfrom
BennoLossin:frontmatter-config

Conversation

@BennoLossin
Copy link

These two configuration options are used to change the way zk obtains the creation date and modification date from a file.

I have a lot of notes that use created and changed as the keys for the creation and modification date (I store them in git and thus the true creation/modification date are useless).

This also is useful when one wants to use a different language for the keys in the frontmatter.

I am pretty new to go and this is my first contribution to zk, so I very likely have missed something.

@BennoLossin
Copy link
Author

Ah I just noticed that I didn't finish the tesh files correctly... I'll get to that tomorrow, never used tesh before and the make tesh command didn't result in any errors, so I didn't know what the correct output should be.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale No recent activity label Apr 26, 2025
@github-actions github-actions bot removed the stale No recent activity label Apr 27, 2025
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale No recent activity label May 28, 2025
@BennoLossin BennoLossin force-pushed the frontmatter-config branch from 541535e to 30d1a9a Compare May 28, 2025 16:15
@github-actions github-actions bot removed the stale No recent activity label May 29, 2025
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale No recent activity label Jun 29, 2025
@tjex tjex removed the stale No recent activity label Oct 1, 2025
@tjex
Copy link
Member

tjex commented Oct 1, 2025

Hey, sorry for being slow here. Got some stable free time back now.

Can you explain why this is needed and what effect these changes have for the user?

@tjex tjex self-assigned this Oct 1, 2025
@BennoLossin
Copy link
Author

The motivation is the following: I'm using a git repository to store my notes & sync them between multiple devices. This means that things like zk edit -i --sort=modified don't reflect the actual modification date when I last touched the file, but when git last touched it. That's why the new changed yaml key is needed. Since we now have two dates & times in the yaml frontmatter, it didn't really sound like a good idea to have "date" as a key, since it could lead to confusion. Additionally, I use the created key in my notes before I switched to zk. Thus allow users to specify a custom name for the creation date key in the yaml frontmatter.

The user can specify format.markdown.frontmatter.creation-date-key (default value is "date"), this will replace the existing date key and all logic that uses it. Similarly, the format.markdown.frontmatter.modification-date-key option will allow users to use this key in frontmatter to specify the actual modification date that will take priority over the files mtime. It will be used for things like zk list --sort=modified.

@tjex
Copy link
Member

tjex commented Nov 8, 2025

Sorry again.. So the user would need to update the modification date value in the frontmatter every time the modified the file?

@BennoLossin
Copy link
Author

Indeed, I have set up my editor to do that for me. Other ways to do it are for example git hooks.

@tjex
Copy link
Member

tjex commented Nov 15, 2025

Ok, I'd be down to merge this. But could you also add a quick documentation in the docs about how to automate the updating of modification dates?

eg, in tips

@tjex tjex changed the title add creation-date-key modification-date-key` configuration options add creation-date-key modification-date-key configuration options Nov 25, 2025
@tjex
Copy link
Member

tjex commented Nov 25, 2025

There is now also an effort to auto update the modification date at zk-org/zk-nvim#272

But I'd prefer to support this on the side of the zk binary, and not zk-nvim

Copy link
Contributor

@WhyNotHugo WhyNotHugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I only have very minor suggestions wrt reducing verbosity.

@tjex
Copy link
Member

tjex commented Nov 30, 2025

Ok, I'd be down to merge this. But could you also add a quick documentation in the docs about how to automate the updating of modification dates?

eg, in tips

@BennoLossin

So this is good to go on the code side (thanks to WhyNotHugo), but it' still missing some example config / setup to get this working for users. It's not immediately clear how to set this up, either manually and definitely not to automate it. Both would be great.

E.g, a current note looks like this:

---
title: higher complexity does not always result in more order
date: 2024-01-03
id: u6nh
tags: []
aliases:
---
 
...

How should they add a secondary date to the frontmatter, so that zk knows which is the creation date and the modification date?

This doc also needs to be updated then (which I can do to help drop the workload on documentation if needed). But I really would like docuemntation on how to implement this, with automation (even just a copy and paste snippet in tips, as above).

It's a great feature and it should be used.

BennoLossin and others added 3 commits December 25, 2025 13:52
These two configuration options are used to change the way zk obtains
the creation date and modification date from a file.
Co-authored-by: Hugo <hugo@whynothugo.nl>
Co-authored-by: Hugo <hugo@whynothugo.nl>
@BennoLossin
Copy link
Author

Sorry for the long wait, I was very busy in the last two months.

I added a lot more docs now and also included automation for neovim and git. Would probably be a good idea to also include other common editors like vscode, emacs etc. But I'm not familiar with those, so I'd leave that to others. (I also rebased onto the lastest changes from main)

One thing that also could be done would be to add the changed key to the default configuration i.e. no config changes are needed to make changed: <date> work.

@tjex
Copy link
Member

tjex commented Jan 3, 2026

Fantastic. Thanks for getting back on this <3

Comment on lines 78 to 79

#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashbang in middle of script is erroneous:

Suggested change
#!/usr/bin/env bash

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like I left in a previous script, fixed now

Comment on lines 5 to 7
$ echo "---\ncreated: 2025-03-27 01:18:43\n---\n\n# Note" > note.md
$ zk list -qflink
>{"filename":"note"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this testing anything related to creation date?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have forgotten why I wrote these tests, I removed them, feel free to suggest correct ones :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tesh test would need to execute with filechanges in order to test this functionlity.

So zk new and check the creation date.

Not sure how the modified-date would be tested though, as a note would have to be opened by zk, edited and then saved..

@God-damnit-all
Copy link

I'm really looking forward to this being implemented, the lack of integrated date-tracking is the main reason why I haven't made zk my primary note-taking app.

@WhyNotHugo
Copy link
Contributor

WhyNotHugo commented Jan 26, 2026 via email

@BennoLossin
Copy link
Author

Sorry, I won't have the time to add tests myself, if any of you want to add them, feel free to send them to me or just directly push them if that's possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants