diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7ed7510c4d45e4b9e69313c9575f917847bfc674..cd336c03d0ea33734814fbb2f5d0ce558d71ce7e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,7 +15,10 @@ test-html:
   image: registry.gitlab.com/pages/hugo:0.62.2
   stage: generate-html
   script:
-  - hugo
+  - DEFAULT_BASEURL=${CI_PAGES_URL##http:} # don't force stuff on plain HTTP when publishing on HTTPS
+  - BASEURL=${BASEURL:-$DEFAULT_BASEURL} # set BASEURL in the CI variables to override it
+  - echo "Using base URL '$BASEURL'"
+  - hugo -b "${BASEURL}"
   artifacts:
     paths:
     - public