Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-section pages added to main menu when using sectionPagesMenu #12399

Closed
MTecknology opened this issue Apr 20, 2024 · 2 comments · Fixed by #12403
Closed

Non-section pages added to main menu when using sectionPagesMenu #12399

MTecknology opened this issue Apr 20, 2024 · 2 comments · Fixed by #12403
Assignees
Milestone

Comments

@MTecknology
Copy link

MTecknology commented Apr 20, 2024

What version of Hugo are you using (hugo version)?

First found in hugo_0.123.0_linux-amd64.tar.gz

Does this issue reproduce with the latest release?

Yes.

Starting in v0.123.0, some warnings were printed:

WARN  "aamod/exampleSite/content/contact.md:1:1": duplicate menu entry with identifier "Sample Content" in menu "main"
WARN  "aamod/exampleSite/content/features.md:1:1": duplicate menu entry with identifier "Other Features" in menu "main"

Both pages are rendered using their respective titles/names/paths/weights, however there is an additional entry created at the end of the menu which duplicates the contact.md page. In the most recent release, this warning is removed, but the duplicate entry is still created.

The source I am working on is https://github.com/recoverysource/aamod/

@jmooring
Copy link
Member

jmooring commented Apr 20, 2024

The erroneous "duplicate menu entry with identifier" warning in v0.123.0 was triggered by sectionPagesMenu = 'main' in the site configuration. The erroneous warning was removed with #12349 in v0.125.0.

The remaining problem (either resulting from or exposed by #12349) is that sectionPagesMenu = 'main' is adding non-section pages (e.g., content/contact.md) to the menu.

git clone --single-branch -b hugo-github-issue-12399 https://github.com/jmooring/hugo-testing hugo-github-issue-12399
cd hugo-github-issue-12399
hugo server

Failing test case:

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

	files := `
-- hugo.toml --
disableKinds = ['rss','sitemap','taxonomy','term']
capitalizeListTitles = false
pluralizeListTitles = false
sectionPagesMenu = 'main'
-- content/p1.md --
---
title: p1
---
-- content/s1/p2.md --
---
title: p2
menus: main
---
-- content/s1/p3.md --
---
title: p3
---
-- layouts/_default/list.html --
{{ range site.Menus.main }}<a href="{{ .URL }}">{{ .Name }}</a>{{ end }}
-- layouts/_default/single.html --
{{ .Title }}
`

	b := hugolib.Test(t, files)

	b.AssertFileExists("public/index.html", true)
	b.AssertFileContent("public/index.html", `<a href="/p2/">p2</a><a href="/s1/">s1</a>`)
}

@jmooring jmooring changed the title Confusing "duplicate menu entry with identifier" after v0.123.0 Non-section pages added to main menu when using sectionPagesMenu Apr 20, 2024
@bep bep added this to the v0.125.2 milestone Apr 20, 2024
@bep bep self-assigned this Apr 20, 2024
bep added a commit to bep/hugo that referenced this issue Apr 20, 2024
bep added a commit that referenced this issue Apr 20, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants