HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.19k stars 2.9k forks source link

Translation menu is broken when BaseURL is different for other langs #1503

Closed pjox closed 4 years ago

pjox commented 4 years ago

Describe the bug

After updating to latest commit, the dropdown translation menu appears to be broken, clicking on another language just refreshes the page but does not change the language.

I'm using different baseURLs for the different translations. It used to work well on version 4.6 of Academic. Maybe I missed something on the release notes, but I was not able to find a solution or a breaking change.

This issue is present both in production and in localhost.

To Reproduce

Steps to reproduce the behavior:

  1. Click on the language drop down menu.
  2. Click on any language.
  3. The page refreshes without changing the language.

Expected behavior

Changing the website language, and in my case, changing the url.

Technical details:

gcushen commented 4 years ago

To upgrade from v4.6.0 to v4.7.0-dev, you would have had to update Hugo to v0.60+, a major new version with breaking changes.

Academic's code for translating has not changed between v4.6 and v4.7 and there appears to be no issue with translations generally (without changing baseUrl for each translation), such as on Academic's docs site (which currently uses Academic v4.7-dev with English and Chinese translations).

Therefore, I suspect that any issue with content translation may be related to using a different baseURL for each translation in conjunction with updating your version of Hugo to a major new version with breaking changes (possibly including in the area of content translation with diff. baseUrls). Someone may wish to consider looking into the following:

  1. confirm the issue only arises when using different baseURLs (i.e. test using the same baseURL)
  2. investigate the Hugo changelogs in this area from Hugo v0.60.0 and also v0.61.0 and v0.62.0 (as that's the version @pjox reported using)
pjox commented 4 years ago

I can immediately confirm the issue only arises when using different baseURLs.

I also remember previous versions of Hugo gave me a .RelPermalink related warning when I used translations (and only when using different baseUrls), but this warning has disappeared since upgrading to Hugo v0.60.0+ and using Academic v4.7.0-dev.

I'll try to downgrade the versions of Hugo and Academic to reproduce the warning as I sadly never payed much attention to it and don't remember the exact content of it.

svenn3 commented 4 years ago

I have the exact same problem as @pjox, also working with two different baseURLs. I upgraded to Hugo v.0.62.1 and Academic v4.6. I also checked and corrected any breaking changes occurring with the upgrade since my previous version, but it didn't help!

gcushen commented 4 years ago

OK, thanks for the info on .RelPermalink related warning. Can you try the latest master version - I've changed the translation URL to .Permalink, hopefully might fix the issue which you experienced?

svenn3 commented 4 years ago

I tried your fix and it works! Thank you so much for the fast help!

pjox commented 4 years ago

I can also confirm the problem is gone in the last commit. Thank you for the help! 😄