Skip to content

Windows: mount path with leading slash is found in the project directory #12470

@jmooring

Description

@jmooring

Reference: https://discourse.gohugo.io/t/linux-hugo-for-ubuntu-renders-one-page-less-than-windows-version-from-mounted-folder/49664/7?u=jmooring

On Windows, if a mount path has a leading slash, and that path exists relative to the root of the project directory, Hugo finds the path in the project directory and mounts the directory when it shouldn't. Paths with leading slashes are supposed to be relative to the system root.

func TestFoo(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
[[module.mounts]]
source = "content"
target = "content"
[[module.mounts]]
source = "/content-other" # leading slash
target = "content"
-- content/p1.md --
---
title: p1
---
-- content-other/p2.md --
---
title: p2
---
-- layouts/_default/single.html --
{{ .Title }}
`
	b := hugolib.NewIntegrationTestBuilder(
		hugolib.IntegrationTestConfig{
			T:           t,
			TxtarString: files,
			NeedsOsFS:   true,
		}).Build()

	b.AssertFileExists("public/p1/index.html", true)
	b.AssertFileExists("public/p2/index.html", false) // fails on Windows
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions