ref: 17aafb39ddd04a443994b3cb605970070b274377
parent: 5b3b0f95561b6aab4efc3b6d9fd847669ef1bc61
author: VonC <[email protected]>
date: Mon Aug 12 10:31:24 EDT 2013
Avoid error if no content. The homepage should still be generated. This is useful especially in the beginning, where you start just with the homepage.
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -16,7 +16,6 @@
import (
"bitbucket.org/pkg/inflect"
"bytes"
- "errors"
"fmt"
"github.com/spf13/nitro"
"html/template"
@@ -308,7 +307,7 @@
s.Info.Indexes = s.Indexes.BuildOrderedIndexList()
if len(s.Pages) == 0 {
- return errors.New(fmt.Sprintf("Unable to build site metadata, no pages found in directory %s", s.Config.ContentDir))
+ return
}
s.Info.LastChange = s.Pages[0].Date
@@ -483,11 +482,13 @@
n.Url = Urlize(string(n.Site.BaseUrl))
n.RSSlink = template.HTML(MakePermalink(string(n.Site.BaseUrl), string("index.xml")))
n.Permalink = template.HTML(string(n.Site.BaseUrl))
- n.Date = s.Pages[0].Date
- if len(s.Pages) < 9 {
- n.Data["Pages"] = s.Pages
- } else {
- n.Data["Pages"] = s.Pages[:9]
+ if len(s.Pages) > 0 {
+ n.Date = s.Pages[0].Date
+ if len(s.Pages) < 9 {
+ n.Data["Pages"] = s.Pages
+ } else {
+ n.Data["Pages"] = s.Pages[:9]
+ }
}
x, err := s.RenderThing(n, "index.html")
if err != nil {