Skip to content

Move date from file name to front matter #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 9, 2025

Conversation

senekor
Copy link
Contributor

@senekor senekor commented Mar 8, 2025

I snapshot tested this locally, the output is identical. As always, I made an effort to make the individual commits easy to review.

Motivations:

  • Aparantly it's easy to forget to adjust the file name of a post before merging it. (see here and here) It was suggested here that having the date in the front matter might make it easier to spot.
  • In the future, we may want to add a path key to the front matter, which contains the explicit URL with the date, in order to be able to migrate to Zola. It will be easier to keep date and path in sync. Firstly, because they will be right next to each other, making a discrepancy clearly visible. Secondly, because we already have the front matter strongly typed and tested, so it will be easy to add this simple validation on top.

stacked on #1509

Rendered

senekor added 7 commits March 8, 2025 22:11
Without the date in the file name, there are some name collisions.
These were resolved by inserting `@{counter}` before the file extension.
A later commit will adjust the static site generator to strip this
disambiguator again, such that permalinks stay intact.

The counter is sorted by date, i.e. `foo@0.md` is older than `foo@1.md`.
If a previous run of the static site generator created new files, these
will be left lying around, even if subsequent runs wouldn't generate
that file anymore. This will lead to either a false negative or a false
positive.

- The file shouldn't be generated and isn't.
  Tests incorrectly fail because it's still there.

- The file should be generated but isn't.
  Tests incorrectly pass because it's still there.
@senekor senekor requested a review from Manishearth March 8, 2025 21:44
Base automatically changed from senekor/normalize-front-matter to master March 9, 2025 00:04
@Manishearth Manishearth merged commit 7d46f3c into master Mar 9, 2025
3 checks passed
@Manishearth Manishearth deleted the senekor/date-in-front-matter branch March 9, 2025 00:06
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.

2 participants