From 664a97819f8eea0e1da399148958fe7a2ae2c8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 28 Jun 2015 10:43:43 +0200 Subject: [PATCH] 404 is homeless Fixes #1235 --- hugolib/site.go | 2 ++ hugolib/site_test.go | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hugolib/site.go b/hugolib/site.go index 0a1e2090e..a4804de95 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1314,7 +1314,9 @@ func (s *Site) RenderHomePage() error { } } + // TODO(bep) reusing the Home Node smells trouble n.URL = helpers.URLize("404.html") + n.IsHome = false n.Title = "404 Page not found" n.Permalink = s.permalink("404.html") diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 5acff8c2a..6ee9287cf 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -398,9 +398,9 @@ func doTest404ShouldAlwaysHaveUglyUrls(t *testing.T, uglyURLs bool) { s.initializeSiteInfo() templatePrep(s) - must(s.addTemplate("index.html", "Home Sweet Home")) - must(s.addTemplate("_default/single.html", "{{.Content}}")) - must(s.addTemplate("404.html", "Page Not Found")) + must(s.addTemplate("index.html", "Home Sweet Home. IsHome={{ .IsHome }}")) + must(s.addTemplate("_default/single.html", "{{.Content}} IsHome={{ .IsHome }}")) + must(s.addTemplate("404.html", "Page Not Found. IsHome={{ .IsHome }}")) // make sure the XML files also end up with ugly urls must(s.addTemplate("rss.xml", "RSS")) @@ -421,9 +421,9 @@ func doTest404ShouldAlwaysHaveUglyUrls(t *testing.T, uglyURLs bool) { doc string expected string }{ - {filepath.FromSlash("index.html"), "Home Sweet Home"}, - {filepath.FromSlash(expectedPagePath), "\n\n

title

\n\n

some content

\n"}, - {filepath.FromSlash("404.html"), "Page Not Found"}, + {filepath.FromSlash("index.html"), "Home Sweet Home. IsHome=true"}, + {filepath.FromSlash(expectedPagePath), "\n\n

title

\n\n

some content

\n IsHome=false"}, + {filepath.FromSlash("404.html"), "Page Not Found. IsHome=false"}, {filepath.FromSlash("index.xml"), "\nRSS"}, {filepath.FromSlash("sitemap.xml"), "\nSITEMAP"}, }