This article explains how to deploy sites to GitLab Pages using GitLab CI.

Workflow#

Create .gitlab-ci.yml at the root of your site with the following contents:

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

variables:
  HUGO_ENV: production

default:
  before_script:
    - apk add --update --no-cache git go npm
    - npm install

test:
  script:
    - hugo --gc --minify

pages:
  script:
    - hugo --gc --minify
  artifacts:
    paths:
      - public

See also Starter Template GitLab Pages Configuration