Can't figure out how to set up Hexo and NGINX Vhosts config.

Posted August 17, 2018 3.9k views
NginxNode.jsMEANInitial Server SetupUbuntu 18.04

Hello everyone,
I need help setting up a blog on my droplet. I have successfully deployed the blog using Hexo at but the problem is that the hexo blog redirects it to Now, I know why it’s happening, its because of the blog config that I set up as:


## If your site is put in a subdirectory, set url as '' and root as '/child/'
root: /blog/public
permalink: :year/:month/:day/:title/

My blog is in /www/data/blog. The reason why I set up the root directory as /blog/public is, the css and everything else break if I don’t. The blog runs fine but only the HTML part.

Here’s the nginx *vhosts.conf *configuration:

server {

    root /www/data/blog/public;
    index index.html index.htm;

        location /

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


Anything other than the setting above results in either breaking the site altogether or mismatched paths.
So, how can I serve my website directly at

  • You will have to fix the paths of css and whatever else you got in order to make it work. If Hexo provides a way to set the paths at install then you should reinstall it otherwise you have to manually change the paths. You could even use something like sed to fix the paths in one go if it’s the same line in all files.

  • @X40C No, Hexo only provides the option to set URL of the root folder as I have mentioned. Since, files will be generated dynamically and new files will be put in manually changing the path of these files doesn’t seem like a good idea, but I’ll try it though.
    I don’t know how to use sed in this case. Can you please elaborate?

  • It seems that Hexo allows you to pick the root directory as well as the domain.

    Website in subdirectory
    If your website is in a subdirectory (such as set url to and set root to /blog/.

    The above is from

  • @X40C As you can see in my hexo’s _config.yml, I have set my domain to and the root directory as /blog/public. If I set it as just /blog or just /, the website breaks.

  • Just installed a Hexo blog on a box with nginx as proxy and everything seems to be working as expected. The website is under blog.domain.tld. I`ve used the default nginx.conf and only added poxypass param to it. I did add the servername and root params as well but nothing was different. This is what the config looks like:

    “` server_name _;

        location /
  • Show 4 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer