Change the language to report an error

Hugo env

$ hugo env

hugo v0.138.0-ad82998d54b3f9f8c2741b67356813b55b3134b9+extended windows/amd64 BuildDate=2024-11-06T11:22:34Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.23.2"
github.com/sass/libsass="3.6.6"
github.com/webmproject/libwebp="v1.3.2"

Problem Description

1.What you were doing or what you tried

I published my locally written blog to the server, allowing users to switch between Chinese and English when reading articles.

2.What you expected

When reading articles, the language switches normally.

3.What actually happened

While running hugo server locally, switching between Chinese and English works without issue.
However, when I upload the public folder to the server, I encounter problems:
it works fine in Chinese, but once I switch to English,
it redirects incorrectly to localhost:xxxxx instead of the IP address.


My repository


Welcome,

the public folder you pushed to your server has been generated using hugo server command. which will replace your baseurl with that localhost:xxxxx

To create a deployable website use hugo only

todo:

  • remove the stuff you deployed
  • generate the site using hugo
  • deploy the resulting public folder to your nginx server.
  • reload or restart the server what ever nginx needs


p.s.
I doubt you did step 4 using hugo server and deploy guess that was hugo only

1 Like

Thank you very much for your reply.
I have tried the following steps, but I still can’t resolve the issue:
(1) Delete the public folder in the directory.
(2) Use the command: hugo server to generate the public folder.
(3) Upload the public folder to the server.

In step 2:

don’t use hugo server

Use:

hugo
2 Likes

Oh my God, this problem that has been tormenting me for hours has finally been resolved. Thank you once again for your response!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.