Hugo Server works but Hugo (build) has no css or js
rebelwarrior opened this issue · comments
When I use hugo server the site looks fine when I use hugo to build the site on public, the css and js don't load and the site looks like a skeleton.
Tried using a baseUrl of "/" as recommended. Same result.
hey there, it doesn't work like that. When you generate hugo
you need to specify the baseURL that you want to publish. then after generate the public folder, you need to upload the file there. then it will work.
Basically what happens is that if the baseURL is set to "/" then the css, js and image (img) files look for files with a double "//" in them. This fails and the site looks undressed. To solve this I re-wrote the calls for css, js and img files on the outputted index.html
file in site to remove the preceding "/". So "/img/icon.png"
would be "img/icon.png"
.
This fixes the problem.
When you go to output for deployment rather than testing locally set the baseUrl correctly to the website's site.