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

[Feature Request] Last Modified Date in post meta #1037

Open
kazettique opened this issue Sep 5, 2022 · 4 comments · May be fixed by #1337
Open

[Feature Request] Last Modified Date in post meta #1037

kazettique opened this issue Sep 5, 2022 · 4 comments · May be fixed by #1337

Comments

@kazettique
Copy link

Does we have any plan to add last modified date beside the create date in post meta?
As I know Hugo provides .Lastmod parameter from Git info variables
It would be great to show the latest modified date on the post.

Thanks & cheers.

@miawithcode
Copy link

hi, I figure how to add last modified out, here is my solution.

  1. config config.yml with:
    enableGitInfo: true

    frontmatter:
        lastmod:
        - lastmod
        - :git
        - date
        - publishDate
  1. add this to layouts/partials/post_meta.html
    {{- if not .Lastmod.IsZero -}}
    {{- $scratch.Add "meta" (slice (printf "<span title='%s'>updated %s</span>" (.Lastmod) (.Lastmod | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
    {{- end }}
  1. Then it is done. I hope it's working for you.

@kazettique
Copy link
Author

@miawithcode Thanks for you kindly suggestion.
In fact, after did some research, I had already added last modified date in post_meta.html.
But before that, I had to copy the whole theme folder then modified it, which meant it would lost git control from original repo (aka. HERE) forever.
I think some people might want the feature. (And for me of course)
That's why I asked it here.

PS. I've read the post you sharing about it, which is nice.

@miawithcode
Copy link

@kazettique okay, I got it.

Ps: Thanks for noticing the blog.XD

@jabbrwcky1
Copy link

@kazettique Also keen to see a last modified date added, thanks for flagging! Same as you, I'm not about to unlink from original on github.

@margau margau linked a pull request Nov 19, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants