Skip to content

feat: Make the date format customisable#85

Open
icyflame wants to merge 1 commit intoyihui:masterfrom
icyflame:sk/make-date-format-customisable
Open

feat: Make the date format customisable#85
icyflame wants to merge 1 commit intoyihui:masterfrom
icyflame:sk/make-date-format-customisable

Conversation

@icyflame
Copy link

Thank you for this great, minimalist Hugo theme. I really like the look and its simplicity. I am completely new to Hugo, but I was able to easily edit the existing templates by looking at the documentation and the example site.

One feature that I wanted was to be able to customize the date format, and display dates as 2006-01-02. This PR adds that feature. This works, but ...

I am not entirely certain that using a partial is the right solution here, as a site-level configuration variable feels more appropriate. However, I was not able to figure out how to define a "default" format without using an if-else block, so I chose to implement this using partials.

The if-else block would reduce the readability of the existing single.html template, as it may look something like this:

{{ if .Site.Params.dateFormat }}{{ .Date.Format .Site.Params.dateFormat }}{{ else }} {{.Date.Format "2006/01/02" }}{{ end }}

@CLAassistant
Copy link

CLAassistant commented Jan 18, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Owner

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Thanks! Using a partial sounds like an overkill for this task. I think a site-level config is more appropriate, and the natural solution is the default function:

{{ .Date.Format (default "2006/01/02" .Site.Params.dateFormat) }}

This patch introduces a new site-level configuration variable to control the date format.

I have added a short usage note inside `about.md`, which would be useful to users of this theme who
are not familiar with the way that time formatting works in Golang.
@icyflame icyflame force-pushed the sk/make-date-format-customisable branch from 3bf6c2c to 8486015 Compare February 8, 2026 14:25
@icyflame
Copy link
Author

icyflame commented Feb 8, 2026

@yihui Thanks for that! The default function would be ideal for this use-case ✅ I have updated this PR, take a look when you can!

@icyflame icyflame requested a review from yihui February 8, 2026 14:29
Copy link
Owner

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Looks good!

@icyflame
Copy link
Author

icyflame commented Feb 11, 2026 via email

@yihui
Copy link
Owner

yihui commented Feb 12, 2026

@icyflame Like most other feature PRs, this one will not be merged. This theme is meant to be a bare minimal one, and those who are interested in learning how to add new features can learn from the pull requests. Apologies for not being clear in the first place, and thanks again for your contribution!

@icyflame
Copy link
Author

icyflame commented Feb 12, 2026 via email

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.

3 participants