Last active
February 16, 2017 01:06
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ dateFormat .Site.Params.DateForm (default .Date (.PublishDate)) }} | |
<!-- Above is the optimized version of below, thanks to https://discuss.gohugo.io/t/how-to-use-the-publishdate-if-both-publishdate-and-date-are-set-in-frontmatter/5142/3?u=kaushalmodi --> | |
{{/* with .PublishDate */}} | |
{{/* if eq ($.PublishDate.Format "2006-01-02") "0001-01-01" */}} | |
<!-- Print the Date instead of PublishDate if PublishDate is defined but at its initial value of Jan 1, 0001 --> | |
{{/* $.Date.Format $.Site.Params.DateForm */}} | |
{{/* else */}} | |
{{/* $.PublishDate.Format $.Site.Params.DateForm */}} | |
{{/* end */}} | |
{{/* end */}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The layout string used by the Parse function and Format method | |
// shows by example how the reference time should be represented. | |
// We stress that one must show how the reference time is formatted, | |
// not a time of the user's choosing. Thus each layout string is a | |
// representation of the time stamp, | |
// Jan 2 15:04:05 2006 MST | |
// An easy way to remember this value is that it holds, when presented | |
// in this order, the values (lined up with the elements above): | |
// 1 2 3 4 5 6 -7 | |
{{ .Date.Format "Jan 2, 2006" }} becomes “Oct 4, 2007” | |
{{ .Date.Format "Jan 02, 2006" }} becomes “Oct 04, 2007” | |
https://www.madboa.com/blog/2016/08/24/hugo-dateformat/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment