commit eda36787429a3087a30991255f5be1576cf3e121
parent c21e2b3b4d759bc84ba080bc35059bb51eb34144
Author: Vincent Batoufflet <vincent@batoufflet.info>
Date: Mon, 27 Jun 2016 17:07:34 +0200
Add automatic page date fallback
Closes #2239
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git 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
}