Hugo - Deploy public folder to local Apache server

By xngo on April 25, 2020

When you build your website using Hugo, it will take all your HTML/Markdown content and generates static files in /public. It also copies over all CSS/JS/etc files that are in your root /static and your theme's folder. Then, you copy the content of /public to your Apache root folder, /var/www/html/. Finally, open http://localhost/index.html. You will see your website. However, you might see missing styling on your website. That is because you already set your baseURL in the config.toml file. I recommend to comment it out and rebuild your website.

Here are the steps that I did for my case.

# Comment out baseURL from config.toml file
 
hugo hugo --buildDrafts
 
cp -a public/* /var/www/html/

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.