HUGO

Automatic publish date?

I know LastMod can be pulled from git metadata, but that’s last update. Is there a variable for file creation date?

File creation date depends on OS and filesystem. For example, here’s the stat output from Ubuntu with an EXT4 filesystem:

  File: myfile.txt
  Size: 5         	Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d	Inode: 2108413     Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/user)   Gid: ( 1000/user)
Access: 2021-09-14 08:22:52.988029191 -0700
Modify: 2021-09-14 08:22:52.988029191 -0700
Change: 2021-09-14 08:22:52.988029191 -0700
 Birth: -

Look at the last line—that’s the creation date.

With a bit of work you can get the access time (atime) and change time (ctime) using the os.Stat function.

You can configure any of the dates to use the file’s ModTime, which, as @jmooring, may not be the same as the creation date. That said, I’m not sure how stable the OS creation date would be, either, in situations where you fetch your files from GitHub.