Repository: gohugoio/hugo (language: go)

Issue:
server:  new pages with space within do not appear until restart in 0.123
[Example site](https://github.com/TiGR/hugo-testing/tree/broken-getterms-issue).

1. Start hugo server
2. Create `content/test test` directory.
3. Create an `index.md` file within, add some basic content.
4. See that the page have not appeared in the list on the website.
5. Restart hugo
6. Notice that the page is there.

Tested on master version.

P.S: uncovered this in attempts to pinpoint another issue with new files not appearing (or not getting updates), but unable to create reproduction example yet. Also, that another issue seems to be windows-only.



Discussion / hints:
Tested on 0.123.1. The issue is still there.

Fix patch:
diff --git a/hugolib/pages_capture.go b/hugolib/pages_capture.go
index b9d7a0ae131..4328978db1c 100644
--- a/hugolib/pages_capture.go
+++ b/hugolib/pages_capture.go
@@ -195,9 +195,9 @@ func (c *pagesCollector) collectDir(dirPath *paths.Path, isDir bool, inFilter fu
 	var dpath string
 	if dirPath != nil {
 		if isDir {
-			dpath = filepath.FromSlash(dirPath.Path())
+			dpath = filepath.FromSlash(dirPath.Unnormalized().Path())
 		} else {
-			dpath = filepath.FromSlash(dirPath.Dir())
+			dpath = filepath.FromSlash(dirPath.Unnormalized().Dir())
 		}
 	}
 


Test patch:
diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go
index 54d6888c093..98a8d0949f8 100644
--- a/hugolib/rebuild_test.go
+++ b/hugolib/rebuild_test.go
@@ -305,6 +305,29 @@ Pages: {{ range .RegularPages }}{{ .RelPermalink }}|{{ end }}$
 	b.AssertFileContent("public/index.html", "Pages: /p1/|/p2/|$")
 }
 
+func TestRebuildAddPageWithSpaceListPagesInHome(t *testing.T) {
+	files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableLiveReload = true
+-- content/asection/s1.md --
+-- content/p1.md --
+---
+title: "P1"
+weight: 1
+---
+-- layouts/_default/single.html --
+Single: {{ .Title }}|{{ .Content }}|
+-- layouts/index.html --
+Pages: {{ range .RegularPages }}{{ .RelPermalink }}|{{ end }}$
+`
+
+	b := TestRunning(t, files)
+	b.AssertFileContent("public/index.html", "Pages: /p1/|$")
+	b.AddFiles("content/test test/index.md", ``).Build()
+	b.AssertFileContent("public/index.html", "Pages: /p1/|/test-test/|$")
+}
+
 func TestRebuildScopedToOutputFormat(t *testing.T) {
 	files := `
 -- hugo.toml --