I’m facing an issue where the site loads fine with the hugo server command, but when served through Nginx with static files, the theme doesn’t load correctly.
BaseURL should be an absolute url, see, Configure Hugo | Hugo
Maybe you could try baseURL: "http://localhost/".
I don’t know why you add the port here.
The default value of relativeURLs is False. It should be OK.
If you have a baseURL set for port 1313, how would the references to localhost:1313 be solved in a site served from port 80?
You could’ve, BTW, just opened the developer tools of your browser and checked their error messages. That would’ve told you which files the browser couldn’t find and where it was looking for them.
Using nginx as a proxy for a running hugo server seems to be a bit contrived – what’s the point of nginx in that context, except to create confusion?
But you do not need the proxy_pass or the hugo server parts at all in production. Hugo does not need to be installed at all on the server.
Hugo outputs all the html, css and js to the “public” directory. That is all you need to upload to the server.
Make sure “baseURL” is set to the actual domain of the production site, something like “https://www.example.com/”. The same domain is then set as “server_name” in Nginx conf.
The Nginx conf is something like this (but you really should use SSL/TLS in production).
server {
listen 80;
server_name www.example.com;
root /Users/pramodchoudhari/personal_projects/my_blog/promode_me/public;
index index.html
location / {
try_files $uri $uri/ /index.html;
}
}
Yes, I will be using public dir on my prod setup with SSL/TLS enabled.
But on local not sure why its not loading properly
Here is the link to repo
Steps to reproduce:
git clone https://github.com/promode1414/promode_me.git
cd promode_me
git clone https://github.com/nanxiaobei/hugo-paper.git themes/hugo-paper
hugo --theme hugo-PaperMod
brew install nginx
# edit the nginx as per the topic mentioned
nginx -t
nginx
# open localhost in the browser
Would appreciate any help or guidance to resolve this issue, as it is the final step in publishing my blog.
Then just create the public/ directory by running hugo (not as server) and set nginx to serve that directory. Do not set your BaseURL to anything other but your production URL.
Using a localhost base URL guarantees that it will not work in deployment. Although you’re seeing that “it’s working fine” locally.
Just drop the idea of having nginx serve what hugo server serves anyway, i.e. localhost:1313.