HUGO

Set custom date when building

I would like to be able to set the date of a build. All the posts with ‘date’ Frontmatter that is in the future relative to this date should not be published. Is there any way to achieve this, instead of using the system date (which I cannot change without root)

I tried with https://github.com/wolfcw/libfaketime, but Hugo doesn’t seem to respect the fake time. date correctly shows the faked time though…

libfaketime will eventually be bypassed by applications that dynamically load
system libraries, such as librt, explicitly themselves instead of relying on
the linker to do so at application start time. libfaketime will not work with
those applications unless you can modify them.

This apparently happens a lot in complex run-time environments, e.g., for
programs written in golang, for some Java Virtual Machine implementations,
etc. Since libfaketime is effectively bypassed in such situations, there’s
nothing we can do about it
.

Can you run hugo in a VM?

No this is in a Docker container in CICD. I am currently trying to manually remove the new posts by comparing them with the last commit date. It would be awesome to be able to pass the current date to Hugo as a flag.