mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Only uglify 404.html on server root
`404.html` needs to be that and not `/404/` in the root. There seem to be content pages in the wild with the name `404` (Hugo docs), so this commit adds an extra check so only root 404 pages ignore the `uglifyURLs`setting. Fixes #1140
This commit is contained in:
@@ -40,13 +40,14 @@ func (pp *PagePub) Translate(src string) (dest string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir, file := filepath.Split(src)
|
dir, file := filepath.Split(src)
|
||||||
|
isRoot := dir == ""
|
||||||
ext := pp.extension(filepath.Ext(file))
|
ext := pp.extension(filepath.Ext(file))
|
||||||
name := filename(file)
|
name := filename(file)
|
||||||
if pp.PublishDir != "" {
|
if pp.PublishDir != "" {
|
||||||
dir = filepath.Join(pp.PublishDir, dir)
|
dir = filepath.Join(pp.PublishDir, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pp.UglyURLs || file == "index.html" || file == "404.html" {
|
if pp.UglyURLs || file == "index.html" || (isRoot && file == "404.html") {
|
||||||
return filepath.Join(dir, fmt.Sprintf("%s%s", name, ext)), nil
|
return filepath.Join(dir, fmt.Sprintf("%s%s", name, ext)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user