mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
There is only one s.PageTarget() - so we cannot change it, even tempoararily. We have to find another solution to this.
... Prevent 404.html from prettifying into 404/index.html Restore @realchaseadams's commit348e123
"Force `UglyUrls` option to force `404.html` file name" which got lost after some refactoring (commit8db3c0b
). Remove the equivalent "force `UglyUrls`" code for `sitemap.xml` because the refactored code now calls `renderAndWriteXML()` which uses `WriteDestFile()` which does not prettify a filename. Fixes #939 (reverted from commitc4c19ad303
)
This commit is contained in:
parent
63ffb916d6
commit
851badcb7e
1 changed files with 13 additions and 6 deletions
|
@ -1249,12 +1249,6 @@ func (s *Site) RenderHomePage() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Force `UglyUrls` option to force `404.html` file name
|
||||
if !s.PageTarget().(*target.PagePub).UglyUrls {
|
||||
s.PageTarget().(*target.PagePub).UglyUrls = true
|
||||
defer func() { s.PageTarget().(*target.PagePub).UglyUrls = false }()
|
||||
}
|
||||
|
||||
n.Url = helpers.Urlize("404.html")
|
||||
n.Title = "404 Page not found"
|
||||
n.Permalink = s.permalink("404.html")
|
||||
|
@ -1274,6 +1268,8 @@ func (s *Site) RenderSitemap() error {
|
|||
|
||||
sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap"))
|
||||
|
||||
optChanged := false
|
||||
|
||||
n := s.NewNode()
|
||||
|
||||
// Prepend homepage to the list of pages
|
||||
|
@ -1299,12 +1295,23 @@ func (s *Site) RenderSitemap() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Force `UglyUrls` option to force `sitemap.xml` file name
|
||||
switch s.PageTarget().(type) {
|
||||
case *target.Filesystem:
|
||||
s.PageTarget().(*target.PagePub).UglyUrls = true
|
||||
optChanged = true
|
||||
}
|
||||
|
||||
smLayouts := []string{"sitemap.xml", "_default/sitemap.xml", "_internal/_default/sitemap.xml"}
|
||||
|
||||
if err := s.renderAndWriteXML("sitemap", "sitemap.xml", n, s.appendThemeTemplates(smLayouts)...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if optChanged {
|
||||
s.PageTarget().(*target.PagePub).UglyUrls = viper.GetBool("UglyUrls")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue