Skip to content
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

Document lastmod #1351

Closed
frank06 opened this issue Aug 13, 2015 · 7 comments
Closed

Document lastmod #1351

frank06 opened this issue Aug 13, 2015 · 7 comments

Comments

@frank06
Copy link

frank06 commented Aug 13, 2015

I have two dates in my front matter:

+++
date = "2015-07-14T12:38:31-03:00"
updated = "2015-08-13T17:20:01-03:00"

In the template I can call {{ .Date.Format "January 2, 2006" }} but {{ .Params.updated.Format "January 2, 2006" }} fails with can't evaluate field Format in type interface {}. Or do I have to specify the type of updated somewhere?

@bep
Copy link
Member

bep commented Aug 13, 2015

It seems undocumented, but you should use lastmod instead of inventing your own.

We have a discussion board more suitable for questions.

@bep bep changed the title Can't format date Document lastmod Aug 13, 2015
@bep bep added the Docs label Aug 13, 2015
@frank06
Copy link
Author

frank06 commented Aug 13, 2015

Thanks. But isn't that a bug? I have two dates exactly the same: one works and the other doesn't. If I wanted to display randomdate = "2003-08-13T17:20:01-03:00"?

@bep
Copy link
Member

bep commented Aug 13, 2015

Yea... maybe. But that would be a bug/feature request in the TOML parser, see https://github.com/BurntSushi/toml

The thing is, for date and lastmod we know what to parse. For unknown cases, we take what the front matter parser gives us, in this case an ìnterface{}.

@frank06
Copy link
Author

frank06 commented Aug 13, 2015

Sorry, I should ask this in the discussion board. But for the record, {{ .Lastmod.Format "January 2, 2006" }} does not print the latest modified date (I'm modifying the file now, and it prints yesterday's date).

@bep
Copy link
Member

bep commented Aug 13, 2015

and what is the value of

lastmod

in that file's front matter?

If not set, it inherits the datevalue. All this would be clear if documented (it seems like you think it's connected to the last changed timestamp of the file, it isn't). Hopefully. And as this is an open source project, pull requests are always welcome!

@frank06
Copy link
Author

frank06 commented Aug 13, 2015

Thanks @bep . I understand now, date and lastmod are both casted to Date but you need to supply them. 👍 to add this to the docs!

robertbasic added a commit to robertbasic/hugo that referenced this issue Mar 28, 2016
digitalcraftsman pushed a commit that referenced this issue Mar 28, 2016
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
@github-actions
Copy link

github-actions bot commented Apr 8, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants