Deploying hugo site to production - best practises

I am close to finishing my first Hugo project and am looking at the best way to deploy to production.

I’m building the Hugo site within a docker container with ports 1313 for the host and 1313 for the container. I have an apache2 server on a different host, configured as reverse proxy and pointing for my domain to the docker host using 1313 port.

The problem I have is that browser errors are logged to the console:
Source: [/livereload.js?mindelay=10&v=2&port=1313&path=livereload:2:2143]
Description: WebSocket connection to ‘wss://[my.domain]:1313/livereload’ failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

How do I avoid port 1313 to show up in production?
Is there a best practice document to deploy a Hugo site that I can read? I’m wondering If I should be moving the site manually to a folder on the apache2 host and avoid serving from the hugo container.

Thanks!

You definitely should neither use hugo server to serve a site productive nor use pages generated with that command.

Generate your site using hugo and serve the resulting pages with a web server.

1 Like

thanks for the prompt reply @irkode

Can you provide some extra guidance? If I generate the site using hugo and then manually moving the public folder, that would introduce the extra step of copy the folder and prevent me from editing the site on the fly.

If you want to edit the generated HTML, that modification would disappear after the next run of Hugo. If you’re talking about modifications to the original files (MD, templates, whatever) … well, you must run Hugo to make these changes take effect.

Instead of copying everything over anew, you could use rsync or something similar to only update the changed files. But as @irkode said: You should neither use hugo server as a web server nor copy the public folder generated by that command!

1 Like

Mmh in fact thats the concept of a SSG.

You develop your site an test. If everything is fine you publish.

If you automatically update your live site and make an error, your live site is broken.

Just like developing a program you wouldnt want every change to get automatically released

If you really want to get each update life you could use a file watcher , and build with hugo on changes maybe with a different destination then public and automatically sync to your webserver. Fe using rsync as @chrillek mentioned…but…

I haven’t read the entire thread here, but if you want to have auto rebuilds to production, you can run

hugo -w

On your web server.

Hi Irkode,
I would like to know what deploying to production means to you.
Are you talking about copying HTML files to an Apache or Nginx server?
If so, you should check out Jamstack services like Netify and AWS Amplify. (There are many others.)
Your question reminds me of when I started using Hugo, and I just wondered if this is the case.