Check for the presence of pages before setting dates
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 27 Feb 2016 22:25:41 +0000 (23:25 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 27 Feb 2016 22:25:41 +0000 (23:25 +0100)
See #1903

hugolib/site.go

index acf8bb10b16fa4af1148386cc6cdb0668fb398d7..f3e14399b618dac6a83aaa42a9ae3672c5d830c6 100644 (file)
@@ -1711,8 +1711,10 @@ func (s *Site) newHomeNode() *Node {
        n.IsHome = true
        s.setURLs(n, "/")
        n.Data["Pages"] = s.Pages
-       n.Date = s.Pages[0].Date
-       n.Lastmod = s.Pages[0].Lastmod
+       if len(s.Pages) != 0 {
+               n.Date = s.Pages[0].Date
+               n.Lastmod = s.Pages[0].Lastmod
+       }
        return n
 }