diff --git a/hugolib/node.go b/hugolib/node.go index cbc314049..1732cac16 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -33,6 +33,7 @@ type Node struct { Lastmod time.Time Sitemap Sitemap URLPath + IsHome bool paginator *Pager paginatorInit sync.Once scratch *Scratch diff --git a/hugolib/page_test.go b/hugolib/page_test.go index afbedac90..9a65cff47 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -11,6 +11,7 @@ import ( "github.com/spf13/cast" "github.com/spf13/hugo/helpers" "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) var EMPTY_PAGE = "" @@ -368,6 +369,8 @@ func TestCreateNewPage(t *testing.T) { if err != nil { t.Fatalf("Unable to create a page with frontmatter and body content: %s", err) } + + assert.False(t, p.IsHome) checkPageTitle(t, p, "Simple") checkPageContent(t, p, "

Simple Page

\n") checkPageSummary(t, p, "Simple Page") diff --git a/hugolib/site.go b/hugolib/site.go index 10fd5a8c7..1a596bdcf 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1233,6 +1233,7 @@ func (s *Site) RenderSectionLists() error { func (s *Site) newHomeNode() *Node { n := s.NewNode() n.Title = n.Site.Title + n.IsHome = true s.setURLs(n, "/") n.Data["Pages"] = s.Pages return n diff --git a/hugolib/site_test.go b/hugolib/site_test.go index b5d18e710..65ab241b7 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -16,6 +16,7 @@ import ( "github.com/spf13/hugo/target" "github.com/spf13/hugo/tpl" "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) const ( @@ -419,6 +420,10 @@ func doTest404ShouldAlwaysHaveUglyUrls(t *testing.T, uglyURLs bool) { {filepath.FromSlash("sitemap.xml"), "\nSITEMAP"}, } + for _, p := range s.Pages { + assert.False(t, p.IsHome) + } + for _, test := range tests { file, err := hugofs.DestinationFS.Open(test.doc) if err != nil {