-
Notifications
You must be signed in to change notification settings - Fork 911
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
Broken JS and CSS paths with hugo serve
since Hugo v0.123.0
#2053
Comments
Thanks for filing an issue. Can you share a link to your repo? Or provide a small repro? I'm overloaded and won't have the time to look into this for a while. @fekete-robert @deining @LisaFC - might any one of you have time to look into this? |
The original repository is not public, so I made a simplified version without the actual content: https://github.com/mlange-42/knowledge It turns out that the problem does not only occur with the |
Hi @mlange-42 ,
This should fix the JS and CSS path errors when you run Then, in your CI/CD pipeline, try to use the
If I understand it correctly, you can also set environment variable Hope this helps. |
@huanlin 's advice is good, that's what usually I use as well. A slight alternative is to have different config files for the different environments (https://gohugo.io/getting-started/configuration/#configuration-directory) - this is useful if there are other parameters that you want to change between local/production, not only the baseurl. Also, hugo/docsy does some optimizations on the output if the environment is |
@huanlin @fekete-robert Many thanks for advising this workaround. Will give it a try. However, as the non-serve version is also broken, I guess As it worked well before v0.123.0, I still think this is a bug, not sure if on the side of Hugo or Docsy. |
Hey @mlange-42 , the reason I think it is a normal way to do it, is because that is exactly what I did for my Hugo+Docsy websites. The target servers have different environments, so I use However, it's just me. Maybe other guys also find that it is a bug. |
I investigated this issue, thanks for sharing the repo. The culprit is this setting in your
As soon as you set this setting to false or remove the line alltogether, everything works as expected. From the official documentation:
|
Thanks @deining, this fixes the layout issue. However, all the link are broken now, as the folder where the site is served is not included.
instead of (as with canonifyURLs):
The same with |
Environment
hugo version
): hugo v0.123.0-3c8a4713908e48e6523f058ca126710397aa4ed5+extended windows/amd64 BuildDate=2024-02-19T16:32:38Z VendorInfo=gohugoioProblem
I have a Docsy site that is served in a folder of a domain, not on its root, so
baseURL = "https://example.com/knowledge/"
When running
hugo serve
, the layout is completely broken because wrong URLs for built-in JS and CSS files are generated. Note the duplicateknowledge
:The same problem occurs with
scss/main.css
,offline-search-index.json
andjs/click-to-copy.js
.With Hugo v0.122.0, it works fine:
It also seems that the problem does not occur when building the site normally, without
serve
. However, I don't want to test it on the real site, risking breakage.The text was updated successfully, but these errors were encountered: