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.
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!
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…
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.
Hi, I just connected my GitHub with Cloudflare Pages — it’s free and simple.
Every time I sync files to my GitHub, they go to Cloudflare, like magic
Recommended