-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Improve date validation error message and handle blank dates as zero dates #12898
Comments
We only validate the pre-defined 4 dates in Hugo, which have some configurable fall backs: https://gohugo.io/getting-started/configuration/#configure-dates
That's not Hugo's documentation. If you want to be sure about avoiding front matter collisions, but user defined params below
|
Sorry, wrong link — I meant https://gohugo.io/content-management/front-matter/#fields (My main concern is that it was relatively confusing to figure out once it happened, and the edited issue title much better reflects that — thank you!) |
Is there a way to tell Hugo to ignore some files/paths for the date validation? I use template files in Obsidian to pre-populate the front matter in my posts (alternative to
Edit:
I have [frontmatter]
date = [":filename","created"] in my config, so it seems custom date alias are also validated? |
Dates created by other tools, such as DecapCMS, default to empty string when corresponding UI-fields are left empty. In my case, that causes |
@LHSnow yes, I'll added that to the TODO list in the issue title, thanks for the input. |
I've documented the front matter date field aliases: |
Improve the error message and treat empty strings as zero dates. Closes gohugoio#12898
Improve the error message and treat empty strings as zero dates. Closes gohugoio#12898
Improve the error message and treat empty strings as zero dates. Closes gohugoio#12898
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
TL;DR #10717 makes aliases for date front matter variables fail if they aren't correctly formatted, but it's not obvious and some aliases may already have other meanings, and the error message doesn't make it clear what's wrong. (My
published
was a boolean being parsed as date.)Front matter validation failed for me when running most commands, e.g.
Its front matter contained
published: false
and from my perspective the error message could be interpreted in many ways but none clearly helpful to me.This was relatively hard to debug — why does the
published
key, that I used for a template previously, a boolean, fail?The
published
key isn't listed as one of the predefined front matter variables (https://gohugo.io/content-management/front-matter/#fields) and it was a correctly formatted boolean.Tracked it to #10717 and then to https://github.com/gohugoio/hugo/blob/master/resources/page/pagemeta/page_frontmatter.go#L352 which told me that "published" is actually a special variable because it's an alias to
publishDate
, which is expected to be a date, and it fails when it isn't.Also
published
is a boolean variable in Jekyll, and many might still have it set (though no idea how many except me)I don't have really a proposed solution and it may be an one-off thing, but what might help to make it more transparent:
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
The text was updated successfully, but these errors were encountered: