Hugo build fails on GitLab CI because of the template


I can build my Hugo wiki successfully in local but keep getting failed to extract shortcode: template for shortcode "columns" not found on GitLab CI, suggesting that the template does not install successfully.

Here is the .gitlab-ci.yml (that contains the theme install as well):


# Set this if you intend to use Git submodules
  HUGO_ENV: production

    - apk add --update --no-cache git go
    - git submodule update --init --recursive
    - hugo mod init
    - hugo mod get -u

    - hugo

    - hugo
      - public

Here is the full backrace of the build:

Getting source from Git repository 00:02
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/wiki/wiki/.git/
Checking out 5e68f8cf as main...
Updating/initializing submodules recursively with git depth set to 20...
Synchronizing submodule url for 'themes/hugo-book'
Entering 'themes/hugo-book'
Entering 'themes/hugo-book'
HEAD is now at 6090fdd (MAINT) Respect LinkTitle in page metadata (#483)
Entering 'themes/hugo-book'
Entering 'themes/hugo-book'
Executing "step_script" stage of the job script
Using docker image sha256:c15bbf435d4a35aed7ae14b1291c42f2dae63c591050f02c304e7122929875e0 for with digest ...
$ apk add --update --no-cache git go
(1/10) Installing binutils (2.39-r2)
(2/10) Installing libgomp (12.2.1_git20220924-r3)
(3/10) Installing libatomic (12.2.1_git20220924-r3)
(4/10) Installing gmp (6.2.1-r2)
(5/10) Installing isl25 (0.25-r0)
(6/10) Installing mpfr4 (4.1.0-r0)
(7/10) Installing mpc1 (1.2.1-r1)
(8/10) Installing gcc (12.2.1_git20220924-r3)
(9/10) Installing musl-dev (1.2.3-r1)
(10/10) Installing go (1.19.2-r0)
Executing busybox-1.35.0-r18.trigger
OK: 574 MiB in 37 packages
$ git submodule update --init --recursive
$ hugo mod init
go: creating new go.mod: module
go: to add module requirements and sums:
	go mod tidy
$ hugo mod get -u
go: downloading v0.0.0-20221005080103-6090fddebdf7
go: added v0.0.0-20221005080103-6090fddebdf7
$ hugo
Start building sites … 
hugo v0.105.0-0e3b42b4a9bdeb4d866210819fc6ddcf51582ffa+extended linux/amd64 BuildDate=2022-10-28T12:29:05Z VendorInfo=gohugoio
Error: Error building site: "/builds/wiki/wiki/content/": failed to extract shortcode: template for shortcode "columns" not found
Total in 15 ms
Cleaning up project directory and file based variables 00:03
ERROR: Job failed: exit code 255

It looks like you’re installing the theme as a git submodule AND as a Hugo module. Am I reading the log correctly?

Yes somehow I ended up in mixing both git submodules and Hugo modules in trying to install this theme.

For instance getting the module works locally (Hugo 0.82) but not on the server (v0.105.0):

$ hugo mod get -u
WARN 2022/11/01 19:01:06 module "" not found; either add it as a Hugo Module or store it in "/builds/wiki/wiki/themes".: module does not exist
go: go.mod file not found in current directory or any parent directory.

Here’s an example project hosted on GitLab using the Hugo Book Theme installed as a Git submodule.

I simply followed these instructions:

Thanks it works! I had consulted these docs too but struggled to deploy it properly with the right theme.

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