Building Hugo from source

I followed this process but it hangs at step 6 (inside a cloned Hugo source code folder). It just cancels itself after several minutes.

This also fails (with admin permission for Git).

CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest

I use that process every couple of weeks to build on Windows. The GCC compiler is slow and eats CPU. Maybe your system is over-taxed?

I think so based on the Task Manager. The few times it connected the build disconnected midway. I have spent hours on this, so I will just stop here and just wait for the official release.

I just realized that the post you were reading is outdated:
https://discourse.gohugo.io/t/golang-newbie-keen-to-contribute/35087/5

The build from source section of the Windows installation instructions…

image

…points to this Tips & Tricks topic:
https://discourse.gohugo.io/t/gcc-compiler-required-to-build-hugo-from-source-on-windows/41370

It’s mostly the same, but the compiler version is different.

You might give this a try if you have the time and inclination.


I will edit the outdated post.

Alright. Do I need to download the Ming source code as well? (Like we do with Hugo?)

No. Just this one:

https://github.com/niXman/mingw-builds-binaries/releases/download/13.2.0-rt_v11-rev0/x86_64-13.2.0-release-posix-seh-msvcrt-rt_v11-rev0.7z

Alright. Still froze at the Hugo installation command. Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz 2.30 GHz and 8GB RAM. I cannot now figure out why it is not installing.

$ gcc --version
gcc.exe (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ go version
go version go1.21.6 windows/amd64

Edit: There is a hugo.exe file in C:\Program Files\Go\bin\bin and I had to add that to the path for the commands to work. It seems running hugo comands in there shows the version for example. Also, where hugo does not work but which hugo does.

Just add that directory to your path environment variable, and you’re all set.

Is this expected?

Your setup doesn’t look right to me.

Your GOPATH should be in your user profile, not in Program Files.

And %USERPROFILE%\go\bin should be in your PATH:

image

And when you’re doing changing this stuff, close all terminals, then open a new one to test.

Obviously, when you change the GOPATH, you’ll need to build Hugo again.

Go was installed in Program Files.

This is correct.

Edit: There is a hugo.exe file in C:\Program Files\Go\bin\bin

If you’ve configured things correctly, the path above doesn’t make any sense.

I did a lot of trial and error. I will try a fresh install and see.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.