From 73d923e95d8ca5c59dea4da920693ead1649f0ab Mon Sep 17 00:00:00 2001
From: bep <bjorn.erik.pedersen@gmail.com>
Date: Mon, 19 Jan 2015 02:40:34 +0100
Subject: [PATCH] Fix HugoInfo init

See #570
---
 hugolib/hugo.go |  6 +++---
 hugolib/node.go |  9 ++++++++-
 hugolib/site.go | 10 +++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/hugolib/hugo.go b/hugolib/hugo.go
index 67c048df..24b09b2e 100644
--- a/hugolib/hugo.go
+++ b/hugolib/hugo.go
@@ -7,7 +7,7 @@ var (
 	BuildDate  string
 )
 
-// Hugo contains all the information about the current Hugo environment
+// HugoInfo contains information about the current Hugo environment
 type HugoInfo struct {
 	Version    string
 	Generator  string
@@ -15,8 +15,8 @@ type HugoInfo struct {
 	BuildDate  string
 }
 
-func NewHugoInfo() HugoInfo {
-	return HugoInfo{
+func newHugoInfo() *HugoInfo {
+	return &HugoInfo{
 		Version:    Version,
 		CommitHash: CommitHash,
 		BuildDate:  BuildDate,
diff --git a/hugolib/node.go b/hugolib/node.go
index f6d583a6..8619b7c8 100644
--- a/hugolib/node.go
+++ b/hugolib/node.go
@@ -29,7 +29,7 @@ type Node struct {
 	Params      map[string]interface{}
 	Date        time.Time
 	Sitemap     Sitemap
-	Hugo        *HugoInfo
+	hugo        *HugoInfo
 	UrlPath
 }
 
@@ -78,6 +78,13 @@ func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool {
 	return false
 }
 
+func (n *Node) Hugo() *HugoInfo {
+	if n.hugo == nil {
+		n.hugo = newHugoInfo()
+	}
+	return n.hugo
+}
+
 func (n *Node) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool {
 	if parent.HasChildren() {
 		for _, child := range parent.Children {
diff --git a/hugolib/site.go b/hugolib/site.go
index 058ccd66..c7cbec4e 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -67,7 +67,6 @@ type Site struct {
 	Taxonomies  TaxonomyList
 	Source      source.Input
 	Sections    Taxonomy
-	Hugo        HugoInfo
 	Info        SiteInfo
 	Shortcodes  map[string]ShortcodeFunc
 	Menus       Menus
@@ -341,7 +340,6 @@ func (s *Site) initialize() (err error) {
 
 	s.Menus = Menus{}
 
-	s.Hugo = NewHugoInfo()
 	s.initializeSiteInfo()
 
 	s.Shortcodes = make(map[string]ShortcodeFunc)
@@ -369,7 +367,6 @@ func (s *Site) initializeSiteInfo() {
 		Menus:           &s.Menus,
 		Params:          params,
 		Permalinks:      permalinks,
-		Hugo:            &s.Hugo,
 	}
 }
 
@@ -731,10 +728,10 @@ func (s *Site) assembleSections() {
 
 		for i, wp := range s.Sections[k] {
 			if i > 0 {
-				wp.Page.NextInSection = s.Sections[k][i - 1].Page;
+				wp.Page.NextInSection = s.Sections[k][i-1].Page
 			}
-			if i < len(s.Sections[k]) - 1 {
-				wp.Page.PrevInSection = s.Sections[k][i + 1].Page;
+			if i < len(s.Sections[k])-1 {
+				wp.Page.PrevInSection = s.Sections[k][i+1].Page
 			}
 		}
 	}
@@ -1194,7 +1191,6 @@ func (s *Site) NewNode() *Node {
 	return &Node{
 		Data: make(map[string]interface{}),
 		Site: &s.Info,
-		Hugo: &s.Hugo,
 	}
 }
 
-- 
2.30.2