From: Vincent Batoufflet Date: Mon, 27 Jun 2016 15:07:34 +0000 (+0200) Subject: Add automatic page date fallback X-Git-Tag: v0.17~269 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=eda36787429a3087a30991255f5be1576cf3e121;p=brevno-suite%2Fhugo Add automatic page date fallback Closes #2239 --- diff --git a/hugolib/page.go b/hugolib/page.go index 198f7ba1..000551ec 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -663,6 +663,13 @@ func (p *Page) update(f interface{}) error { p.Draft = !*published } + if p.Date.IsZero() { + fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), p.File.Path())) + if err == nil { + p.Date = fi.ModTime() + } + } + if p.Lastmod.IsZero() { p.Lastmod = p.Date }