Continuous deployment with GitLab


In this tutorial, we will use GitLab to build, deploy, and host a Hugo site. With Hugo and GitLab, this is incredibly easy.

It is assumed that you know how to use git for version control and have a GitLab account, and that you have gone through the quickstart guide and already have a Hugo site on your local machine.

Create .gitlab-ci.yml

cd your-hugo-site

In the root directory of your Hugo site, create a .gitlab-ci.yml file. The .gitlab-ci.yml configures the GitLab CI on how to build your page. Simply add the content below.

image: publysher/hugo

  - hugo
    - public
  - master

Push Hugo site to GitLab

Next up, create a new repository on GitLab. It is not necessary to set the repository public. In addition, you might want to add /public to your .gitignore file, as there is no need to push compiled assets to GitLab.

# initialize new git repository
git init

# add /public directory to our .gitignore file
echo "/public" >> .gitignore

# commit and push code to master branch
git add .
git commit -m "Initial commit"
git remote add origin
git push -u origin master

Wait for your page to be built

That’s it! You can now follow the CI agent building your page at After the build has passed, your new website is available at

Suggested next steps

GitLab supports using custom CNAME’s and TLS certificates, but this is out of the scope of this tutorial. For more details on GitLab Pages, see