How to update a post via command?

Hello guys,

I am trying to update a post via command. E.g. I created a post via hugo new post/test.md, and I will get

---
title: "Test"
slug: test
author: hzb
lastmod: 2019-02-01T05:06:58Z
date: 2019-02-01T05:06:58Z
tags: ["test"]
---

Test

If I don’t update the time lastmod by manually changing, how should I do? I would like the time lastmod is updated automatically when I open it via a command.

Thank you.

That is not possible.

I would remove .Lastmod from front matter.

When you access .Lastmod from a template, the returned value will depend on your site configuration. For example:

[frontmatter]
lastmod = ['lastmod', ':git', ':fileModTime', 'date', 'publishDate']

The template will first look for the .Lastmod value in front matter. If it can’t find that, it will use the latest Git author date. If it can’t find that, it will use the file modification time from the file system, etc.

I see, thank you so much.

If you want to access the commit date, you need to set enableGitInfo = true in your site configuration.

Thank you, I read the help doc Site Configuration you gave, and solved the this question.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.