mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-16 21:44:05 +00:00
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.
This commit is contained in:
parent
5b3b0f9556
commit
ab7beb3da7
1 changed files with 8 additions and 7 deletions
|
@ -16,7 +16,6 @@ package hugolib
|
|||
import (
|
||||
"bitbucket.org/pkg/inflect"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/spf13/nitro"
|
||||
"html/template"
|
||||
|
@ -308,7 +307,7 @@ func (s *Site) BuildSiteMeta() (err error) {
|
|||
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 @@ func (s *Site) RenderHomePage() error {
|
|||
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 {
|
||||
|
|
Loading…
Reference in a new issue