How to get a date to not have time

How can I get a date format of April 30, 2019?
My achetype = date: {{ .Date }}
This generates
date: 2019-04-30T12:50:44-06:00 in front matter
My html is

<h3>
        Episode # 
        {{ range last 1 .Pages}}
            {{.Params.episodeNumber}}
        {{end}}
         - 
        {{ range last 1 .Pages}}
            {{.Params.title}}
        {{end}}
        - 
        {{ range last 1 .Pages}}
            {{.Params.date}}
        {{end}}
    </h3>

This produces:
### Episode # 3 - Rockgasms - 2019-04-27 23:43:11 -0600 MDT

I can see there is a Date.Format but not guidance on where you use it, is it in the archetype, or in the html. I’ve honestly been trying to get this tor work for over 4 hours and nothing I try works.
I am pretty much at the point of just taking the date off of that section of the site but the perfectionist side really wants it to work.

Hi, what you want is:

{{ .Date.Format "January 2, 2006" }}

GoLang date formatting in kinda peculiar in that way. See this doc for more examples: https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference

3 Likes

Thank you for the response, is that in the archetype default file I put that?

Nope. Put that in your template

Thank you so much. Fixed it now.

You can also specify this in your archetype file(s), e.g., here’s an excerpt of one of my archetype files:

date: {{ dateFormat "2006-01-02" .Date }}
# publishDate: {{ dateFormat "2006-01-02" .Date }}
# lastmod: {{ dateFormat "2006-01-02" .Date }}
## next are non-built-in parameters
# datecreated: {{ dateFormat "2006-01-02" .Date }}

When I publish a doc, I edit and uncomment the publishDate line. When I modify a doc after publication, I edit and uncomment the lastmod line.

BTW, I have not published my Hugo site yet :crazy_face:

@_nm is right. But I would be careful with this approach because if you ever want the “time” part of the date in the future you’ll be out of luck