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.
Create a new project in GitLab using the name
StephenMichaelis.gitlab.io, GitLab sees
<gitlab-username>.gitlab.io and knows this is to be a hosted Page.
.gitlab-ci.yml file with the following content:
image: monachus/hugo variables: GIT_SUBMODULE_STRATEGY: recursive pages: script: - hugo artifacts: paths: - public only: - 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 https://github.com/eueung/hugo-casper-two themes/casper-two git add . git commit -m "Initial commit" git remote add origin https://gitlab.com/StephenMichaelis/stephenmichaelis.gitlab.io.git git pull https://gitlab.com/StephenMichaelis/stephenmichaelis.gitlab.io.git 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
Link Custom DNS to GitLab Page
To link my DNS http://memorylapse.ca to https://stephenmichaelis.gitlab.io 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
184.108.40.206. These are the settings I changed with my DNS provider.
|memorylapse.ca||TXT||_gitlab-pages-verification-code.memorylapse.ca 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