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

🐛 Fix menu localization: site.Menus URLs are already localized #1623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

npellegrin
Copy link

What does this PR change? What problem does it solve?

It appears that a website having a custom base URL generate invalid menu links using this template.
The reason is a computation of localization using absLangURL over site.Menus -> .URL items.

In recent versions of Hugo, the site.Menus items are already localized. You can see in the official example here, there is no absLangURL declared after .URL: https://gohugo.io/templates/menu/#example

absLangURL should be used to convert a relative URL to a localized URL in case the URL is not localized yet. Calling a already-localized URL with absLangURL will append the language code twice. The problem may be not visible without declaring a custom baseURL because Hugo seems to automatically strip duplicated localization codes for ease.

Was the change discussed in an issue or in the Discussions before?

I have not seen any issue about that, feel free to point it out if I missed it.

PR Checklist

  • This change adds/updates translations and I have used the template present here.
  • I have enabled maintainer edits for this PR.
  • I have verified that the code works as described/as intended.
  • This change adds a Social Icon which has a permissive license to use it.
  • This change does not include any CDN resources/links.
  • This change does not include any unrelated scripts such as bash and python scripts.
  • This change updates the overridden internal templates from HUGO's repository.

Copy link

sonarcloud bot commented Oct 21, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant