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

navigation.Page is nil for taxonomy pages (Hugo v0.128.2 ) #12652

Closed
hacdias opened this issue Jul 10, 2024 · 4 comments
Closed

navigation.Page is nil for taxonomy pages (Hugo v0.128.2 ) #12652

hacdias opened this issue Jul 10, 2024 · 4 comments

Comments

@hacdias
Copy link
Contributor

hacdias commented Jul 10, 2024

Hi!

Since Hugo 0.128.2, it seems that the menu navigation is not working as it did before. To be specific, the pageRef cannot find pages by their output permalink. Here's a bit of my config.toml, where you can see my taxonomies and menu. Note that /articles and /photos are categories.

[permalinks]
  tags = '/tags/:title/'
  categories = '/:title/'

[menu]
[[menu.main]]
  name = '🧁 About'
  pageRef = '/about'
  weight = 1
[[menu.main]]
  name = '✉️ Contact'
  pageRef = '/contact'
  weight = 2
[[menu.main]]
  name = '✏️ Articles'
  pageRef = '/articles'
  weight = 3
[[menu.main]]
  name = '📸 Photos'
  pageRef = '/photos'
  weight = 4
[[menu.main]]
  name = '📖 Guestbook'
  pageRef = '/guestbook'
  weight = 5
[[menu.main]]
  name = '🌈 More'
  pageRef = '/more'
  weight = 6

Here's the code that fails:

{{ range .Site.Menus.main -}}
  {{ .Page.Permalink }}
{{ end }}

With the following error:

executing "partials/base/header.html" at <.Page.Permalink>: nil pointer evaluating navigation.Page.Permalink

From my tests, it seems that .Page is now nil for /articles and /photos, where it used to be correctly populated. The workaround is to just change it to /categories/articles and /categories/photos. That way didn't work before 0.128.2, but seems to be necessary now.

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

$ hugo version
hugo v0.128.2 extended darwin/arm64 BuildDate=2024-07-04T08:13:25Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes, it is a new issue since 0.128.2. Since commit 8cf96f2 to be exact.

@hacdias hacdias changed the title Cannot get .Page.Permalink from navigation object (Hugo v0.128.0 ) navigation.Page.Permalink is not defined (Hugo v0.128.0 ) Jul 10, 2024
@hacdias hacdias changed the title navigation.Page.Permalink is not defined (Hugo v0.128.0 ) navigation.Page.Permalink is not defined (Hugo v0.128.1 ) Jul 10, 2024
@hacdias hacdias changed the title navigation.Page.Permalink is not defined (Hugo v0.128.1 ) navigation.Page.Permalink is not defined (Hugo v0.128.2 ) Jul 10, 2024
@hacdias hacdias changed the title navigation.Page.Permalink is not defined (Hugo v0.128.2 ) navigation.Page is nil for taxonomy pages (Hugo v0.128.2 ) Jul 10, 2024
@bep
Copy link
Member

bep commented Jul 10, 2024

See #12638. There's a long story here and I think I introduced this when we got content adapters into the mix, but:

  • We cannot resolve /articles to /categories/articles in the general case. You could possibly argue that we could do it in the menu setup, but I'm not going to complicate this further.
  • Note that articles (without a leading slash) would resolve to /categories/articles (assuming that there's no other page at that path).

I'm going to close this as "will not fix". I do apologise if I broke something, it was not my intention (or, at least the intention was ... nobel).

@bep bep closed this as completed Jul 10, 2024
@hacdias
Copy link
Contributor Author

hacdias commented Jul 10, 2024

@bep it's perfectly fine, I just didn't expect this coming from a patch release 😅. I would perhaps update the release notes to clearly mention this problem, as I did not find it very clear.

Nevertheless, thanks for you continuous work on Hugo!

@bep
Copy link
Member

bep commented Jul 10, 2024

I just didn't expect this coming from a patch release 😅

Yea, well ... In my head it fixed a breaking bug, which is what patch/bug releases are for.

Copy link

github-actions bot commented Aug 1, 2024

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 Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants