diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-25 20:31:43 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 0aaf3c56a511c6582db4dbfb28879e964e6f2d92 (patch) | |
tree | c85b6d7dc51dcbc7122efabb2a29d0a031752629 /hugolib | |
parent | ee4a33b14ff2b0a2d9130415e16d1046f72573f7 (diff) |
hugolib: Fix panic for Permalink in 404 etc. templates
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/page_paths.go | 2 | ||||
-rw-r--r-- | hugolib/site_render.go | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go index 00d96c05c..0d1b1c363 100644 --- a/hugolib/page_paths.go +++ b/hugolib/page_paths.go @@ -71,7 +71,7 @@ type targetPathDescriptor struct { // and URLs for this Page. func (p *Page) createTargetPathDescriptor(t output.Format) (targetPathDescriptor, error) { if p.targetPathDescriptorPrototype == nil { - panic("Must run initTargetPathDescriptor()") + panic(fmt.Sprintf("Must run initTargetPathDescriptor() for page %q, kind %q", p.Title, p.Kind)) } d := *p.targetPathDescriptorPrototype d.Type = t diff --git a/hugolib/site_render.go b/hugolib/site_render.go index fdac03489..5f46bd0c9 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -216,11 +216,16 @@ func (s *Site) render404() error { } p := s.newNodePage(kind404) + p.Title = "404 Page not found" p.Data["Pages"] = s.Pages p.Pages = s.Pages p.URLPath.URL = "404.html" + if err := p.initTargetPathDescriptor(); err != nil { + return err + } + nfLayouts := []string{"404.html"} return s.renderAndWritePage("404 page", "404.html", p, s.appendThemeTemplates(nfLayouts)...) @@ -245,6 +250,9 @@ func (s *Site) renderSitemap() error { page := s.newNodePage(kindSitemap) page.URLPath.URL = "" + if err := page.initTargetPathDescriptor(); err != nil { + return err + } page.Sitemap.ChangeFreq = sitemapDefault.ChangeFreq page.Sitemap.Priority = sitemapDefault.Priority page.Sitemap.Filename = sitemapDefault.Filename @@ -252,6 +260,11 @@ func (s *Site) renderSitemap() error { n.Data["Pages"] = pages n.Pages = pages + // TODO(bep) output + if err := page.initTargetPathDescriptor(); err != nil { + return err + } + // TODO(bep) this should be done somewhere else for _, page := range pages { if page.Sitemap.ChangeFreq == "" { @@ -284,6 +297,9 @@ func (s *Site) renderRobotsTXT() error { } n := s.newNodePage(kindRobotsTXT) + if err := n.initTargetPathDescriptor(); err != nil { + return err + } n.Data["Pages"] = s.Pages n.Pages = s.Pages |