diff options
-rw-r--r-- | hugolib/menu_test.go | 32 | ||||
-rw-r--r-- | hugolib/site.go | 4 |
2 files changed, 35 insertions, 1 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index 751608246..810b9fe20 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -621,3 +621,35 @@ Menu Item: 0: <span>Home</span>|/| `) } + +// Issue #11062 +func TestMenusSubDirInBaseURL(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com/foo/" +title = "Hugo Menu Test" +[menus] +[[menus.main]] +name = "Posts" +url = "/posts" +weight = 1 +-- layouts/index.html -- +{{ range $i, $e := site.Menus.main }} +Menu Item: {{ $i }}|{{ .URL }}| +{{ end }} +` + + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/index.html", ` +Menu Item: 0|/foo/posts| +`) + +} diff --git a/hugolib/site.go b/hugolib/site.go index 19821e8b2..035f543ee 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -789,8 +789,10 @@ func (s *Site) assembleMenus() { navigation.SetPageValues(me, p) } } + } - } else { + // If page is still nill, we must make sure that we have a URL that considers baseURL etc. + if types.IsNil(me.Page) { me.ConfiguredURL = s.createNodeMenuEntryURL(me.MenuConfig.URL) } |