Skip to content
Building from sources

Building from sources

Building the extended + withdeploy edition of Hugo from source requires the following dependencies:

  1. The Go toolchain
  2. The Git version control system
  3. A C/C++ compiler, such as GCC or Clang

Windows users can use the Chocolatey package manager in order to use the MinGW compiler. After installing Chocolatey, run the following command in an elevated terminal prompt:

choco install mingw

Then, clone the repository and run the build script:

git clone --recurse-submodules https://github.com/agriyakhetarpal/hugo-python-distributions@main
python -m venv venv
source venv/bin/activate

and then install the package in the current directory:

pip install .

or perform an editable installation via the following command:

pip install -e .

Cross-compiling for different architectures

Cross-compilation is experimental and may not be stable or reliable for all use cases. If you encounter any issues, please feel free to open an issue.

This project is capable of cross-compiling Hugo binaries for various platforms and architectures. Cross-compilation is provided for the following platforms:

  1. macOS; for the arm64 and amd64 architectures via the Xcode toolchain,
  2. Linux; for the arm64, amd64, s390x, and ppc64le architectures via the Zig toolchain, and
  3. Windows; for the amd64, arm64, and x86 architectures via the Zig toolchain.

Say, on an Intel-based (x86_64) macOS machine:

export GOARCH="arm64"
pip install .  # or pip install -e .

This will build a macOS arm64 binary distribution of Hugo that can be used on Apple Silicon-based (arm64) macOS machines. To build a binary distribution for the target Intel-based (x86_64) macOS platform on the host Apple Silicon-based (arm64) macOS machine, you can use the following command:

export GOARCH="amd64"
pip install .  # or pip install -e .

For a list of supported distributions for Go, please run the go tool dist list command on your system. For a list of supported targets for Zig, please refer to the Zig documentation for more information or run the zig targets command on your system.

Cross-compilation for a target platform and architecture from a different host platform and architecture is also possible, but it remains largely untested at this time. Currently, the Zig compiler toolchain is known to work for cross-platform, cross-architecture compilation.