Once I had some sample content in place, the next step was to deploy the site to Netlify. It is possible to set up continuous deployment, which means that Netlify monitors a designated Git repository for changes to a specified build (typically main) and automatically runs a build whenever changes are detected.
In the case of a Hugo site, the continuous deployment process works as follows:
-
You push the site to your Git repository (in my case GitHub).
-
In Netlify, you create a link to the repo and specify some build parameters, including the branch that Netlify monitors for changes. Netlify provides typical default values for most of these parameters, making the setup very easy.
-
You then initiate the first deployment of the site.
In the process of deploying, Netlify fires up an entire build environment for Hugo plus any dependencies (more on that in a moment), generates the site, and then destroys the build environment. All of this takes seconds, but it does mean that a Hugo deployment consumes some of your allocation of Netlify build minutes.
The first time I tried to deploy the site, the build failed. I suspected this was because I was using AsciiDoc in place of Markdown and so had AsciiDoctor as an additional dependency that the Netlify build environment needed to be configured for. An online search confirmed that this was the case. A further dependency existed for the Rouge gem, used for syntax highlighting.
I discovered that I needed to add a Gemfile
(no file extension) and Gemfile.lock
file in the same folder as the netlify.toml
file.
-
Go to the root folder of your Hugo project.
-
In a text editor, create a file with the following content and save it as
Gemfile
:Gemfilesource 'https://rubygems.org' gem 'asciidoctor' gem 'rouge'
-
Install
bundler
by running this command in Windows terminal (or at the command prompt):gem install bundler
-
Run bundler:
bundle install
.The result should be a
Gemfile.lock
file with content like the following:Gemfile.lockGEM remote: https://rubygems.org/ specs: asciidoctor (2.0.16) rouge (3.26.1) PLATFORMS x64-mingw32 DEPENDENCIES asciidoctor rouge BUNDLED WITH 2.2.33
After pushing the changes to GitHub, rerunning the Netlify deployment succeeded. The deployment took 24 seconds of build time. This is almost certainly longer than a pure Hugo site (with no use of Asciidoctor) would take.