Created + last updated date on post (Academic Theme)

In the academic theme, there’s a feature allowing one to set enableGitInfo = true to use the last git commit on a post to display modification times. But at the moment, this seems to be displayed instead of the actual post date.

I don’t 100% understand the syntax, but it looks like the code is here

<span class="article-date">
    {{ $date := $page.Lastmod.Format site.Params.date_format }}
    {{ if eq $page.Type "publication" }}
      {{ $date = $page.Date.Format (site.Params.publications.date_format | default "January, 2006") }}
    {{ else }}
      {{ if ne $page.Params.Lastmod $page.Params.Date }}
          {{ i18n "last_updated" }}
      {{ end }}
    {{ end }}
    <time>{{ $date }}</time>
  </span>
{{ end }}

I’d like to have both the post date and last updated appear, so instead of “Last updated on Jul 20, 2019”, it would be something like “Jul 17, 2019 (last updated Jul 20, 2019).”

(I opened an issue on the repo, but it got closed without comment, so I’m assuming this is not something the developer is interested in implementing).

See the docs on configuring dates and test out which combination you like.

1 Like

On my site, which does not use the Academic theme, I include the following in a layout file to display both the publish date and the last-updated date.

published {{ .Date.Format .Site.Params.dateFormat1 }}
&bull;
updated {{ .Lastmod.Format .Site.Params.dateFormat1 }}

And in my config.yaml file, I have this:

params:
  dateFormat1: 2006-January-2

Config frontmatter settings affect how .Date and .Lastmod are interpreted. Here’s what I use:

frontmatter:
  date: 
    - publishDate
    - :filename
    - date
    - :fileModTime
  publishDate: 
    - publishDate
    - :filename
    - date
    - :fileModTime
  lastmod: 
    - lastmod
    - :fileModTime
    - date
    - publishDate

Hopefully this will help you figure out how to do this in your theme.

–N (gitless and themeless :sunglasses:)

1 Like

Thanks, this is really helpful. I’ll see if I can get this working on academic and report back.

I’m encountering the same issue.

Did the solution work for you?

Are you deploying your site via Netlify? I suspect it might have something to do with it, since there is no issue when I build my site locally.

I’ve entered an issue here. I suspect yours might have been deleted, because you entered it on the wrong repository.

To be honest, I haven’t had a chance to try it :-/

Yes, I am. That’s interesting… I haven’t checked with a local build.

Oh, didn’t notice they were separate :-/. Reading your issue, it looks like it might be slightly different from what I’m looking for, though related for sure. Will follow that issue with interest.

The issue has now been closed, because it’s apparently not a bug in Academic but in Hugo and/or Netlify. Gcushen kindly pointed to a workaround, however, which is to disable HUGO_ENABLEGITINFO in netlify.toml. Of course this would also disable the “last changed” date, but at least it brings the post date back.