Running your Hugo site from GitLab

I was hosting my website from my QNAP NAS but I found I was constantly updating and fiddling with it. This caused my website to be down a lot. I recently started using GitLab as a code repository and realized it was so much more. I did some research on GitLab Pages and was able to move my HUGO site from my QNAP to GitLab.

I first created a GitLab project and added a Continuous Integration yaml file .gitlab-ci.yml. The CI file will kick off each time I push any code. It will build a docker container that will host my HUGO code.

I was then able to modify the DNS records for my DNS to point to by adding some records through the DNS Manager of my provider.

GitLab Setup

Create a new project in GitLab using the name, GitLab sees <gitlab-username> and knows this is to be a hosted Page.

Add a .gitlab-ci.yml file with the following content:

image: monachus/hugo


  - hugo
    - public
  - master

Push Code to Git

I turned my code into a git project and pushed it to GitLab. Once pushed this should kick off the CI since we created a gitlab-ci.yml file for our project.

git init
echo "/public" >> .gitignore
git submodule add themes/casper-two
git add .
git commit -m "Initial commit"
git remote add origin
git pull master --allow-unrelated-histories
git push -u origin master

Test GitLab Site

Wait a minute or two to allow your container to build then test your link https://<gitlab-username>

To link my DNS to you need to access your DNS records and the GitLab Pages Settings. At the time of this post the IP recomeded in the GitLab instructions was These are the settings I changed with my DNS provider.

NAME TYPE RDATA A CNAME TXT TXT gitlab-pages-verification-code=Your Own Verification from GitLab Pages Settings

Test Custom Site

I had to wait several hours to see results after updating DNS records. Be patient.

Good luck with your own setup.

Be kind, Steve

comments powered by Disqus