Continuously Deploy a Hugo Site with GitLab CI CD and

Hi all, long time no see.. After a few year left a blogging world, i decide to write again in my blog.

In this post i wanna share my step to deploy a hugo static site using gitlab ci cd to I decide to use surge sh because support custom domain with no terms (until i write this ya).


  • Hugo
  • Gitlab Account
  • Surge Cli

Example of workflow : Hugo -> Gitlab CI/CD ->

First you need a hugo site that has been pushed to gitlab. After that, you need create .gitlab-ci.yml like this :

image: node:8-alpine

    - npm install -g surge
    - npm install --save-dev hugo-bin
    - node --version
    - surge --version
    - surge list  --token $SURGE_TOKEN
    - $(npm bin)/hugo version

    - master
    - rm -rf public
    - $(npm bin)/hugo
    - surge --project ./public/ --token $SURGE_TOKEN --domain

Before you push .gitlab-ci.yml you must set surge credentials in gitlab ci/cd configuration. In your local computer, type in terminal surge token and you will be get the token.

Set SURGE_LOGIN with your email, and SURGE_TOKEN with your token what you get from local terminal. And commit your .gitlab-ci.yml. Voila! Your site is deployed and can get access with your domain (or can get free subdomain from