diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go index 9a76ee3b7..28f8b9393 100644 --- a/common/hugo/hugo.go +++ b/common/hugo/hugo.go @@ -61,6 +61,11 @@ type BuildInfo struct { GoVersion string } +// GetBuildDate returns the build date if set by -ldflags="-X github.com/gohugoio/hugo/common/hugo.buildDate=" +func GetBuildDate() string { + return buildDate +} + // GetBuildInfo returns the build info for the current binary. func GetBuildInfo() *BuildInfo { bi := getBuildInfo() diff --git a/hugolib/site.go b/hugolib/site.go index 678fea7cd..9220423c3 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -532,6 +532,10 @@ func newHugoSites( opts.GoVersion = bi.GoVersion } + if opts.BuildDate == "" { + opts.BuildDate = hugo.GetBuildDate() + } + h.hugoInfo = page.NewHugoInfo(opts) var prototype *deps.Deps