Hugo build fails on GitLab CI because of the template

Hello,

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):

image: registry.gitlab.com/pages/hugo/hugo_extended:latest

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

default:
  before_script:
    - apk add --update --no-cache git go
    - git submodule update --init --recursive
    - hugo mod init gitlab.com/pages/hugo
    - hugo mod get -u github.com/alex-shpak/hugo-book

test:
  script:
    - hugo
  rules:
    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH

pages:
  script:
    - hugo
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

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 registry.gitlab.com/pages/hugo/hugo_extended:latest with digest registry.gitlab.com/pages/hugo/hugo_extended@sha256:ac69e17fb09845c86e2267b659acdc8a30bf16304deca5948a0a63f0d4835e87 ...
$ apk add --update --no-cache git go
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
(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 gitlab.com/pages/hugo
go: creating new go.mod: module gitlab.com/pages/hugo
go: to add module requirements and sums:
	go mod tidy
$ hugo mod get -u github.com/alex-shpak/hugo-book
go: downloading github.com/alex-shpak/hugo-book v0.0.0-20221005080103-6090fddebdf7
go: added github.com/alex-shpak/hugo-book 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/_index.md:8:1": 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 github.com/alex-shpak/hugo-book
WARN 2022/11/01 19:01:06 module "github.com/alex-shpak/hugo-book" 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.