NEW 我們Astro v5.1的新blog上線啦 »

· Joseph · DevOps  · 2 min read

Set godaddy domain and build hugo on gitlab pages

The idea comes from…

I read a blog 將 Github Page 串上自己的域名 on Medium.com, and I thought about my bad experience in setting gitlab pages. I think I have to write a blog now, and let me remember how to set it again.

Hugo

First, install go and hugo:

My system is Ubuntu 19.04, so I follow Go wiki instructions.

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

These commands will install latest Go. Then, let’s install hugo following hugo:

snap install hugo --channel=extended

Now, test it: Test go and hugoOkay, system requirements are prepared.

We can use hugo new site SITE_NAME to initialize a site, hugo server -D to see you page.

Gitlab pages

Open a public repository. (You will have earth icon.) gitlab setting

Then, add a gitlab-ci yml file to run CI/CD on gitlab

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

variables:
  GIT_SUBMODULE_STRATEGY: recursive

test:
  script:
  - hugo
  except:
  - master

pages:
  script:
    - hugo --gc
  artifacts:
    paths:
    - public
    expire_in: 1 day
  only:
  - master

Finish! add, commit, and push it!

Check your CI/CD pipeline is passed

The last step on Gitlab is to set pages domain. Go to Settings > Pages > New Domain add your domain. gitlab-pages-1

You will get a CNAME and a TXT settings to set in your godaddy. gitlab-pages-2

But the setting is tricky. Let’s see my Godaddy.

Finally, Godaddy settings

godaddy

I set two A records point to 35.185.44.232, two TXT records corresponding to A and its TXT value. Note that TXT keys are only @ and www. I’ve tried many settings, and only these settings are workable. Alternatively, you can use Cloudflare with the whole keys and values that gitlab provided.

That’s all. Go back to Gitlab pages setting to verify your domain, and then open your website in the browser.

Summary

I use A record instead of CNAME, and set @ and www as TXT records’ key. Otherwise, I can’t verify my domain. There are many setting tutorial on the Internet. Just find and try it!


  1. Gitlab doc
  2. Hugo doc

Related Posts

View All Posts »
Switching from vim to Neovim!

Switching from vim to Neovim!

I've been using Vim for a long time and finally switched to Neovim. The initial thought of switching came after the author of VIM passed away in August 2023, as I didn’t have the time to try other editors. After a year, “vibe coding” grew up, so I started thinking how to integrate AI into my editor and surveying how to use AI in Vim, which led to this journey.

Using Firebase and Firestore with NextJS and Docker - Part 1 - Setup firebase in docker

Using Firebase and Firestore with NextJS and Docker - Part 1 - Setup firebase in docker

Last year, I got a case to use firebase and firestore with Next.js. I've been fullstack many years, so I haven't tried to use firebase and firestore. There was a great chance to give it a try. In this article I'll show how to use firebase and firestore in Docker and Next.js. If you don't have backend support, or you don't want to build whole backend, database, and infrastructure, you would probably think this is a useful way.

Install Docker / Docker-compose on CentOS 8

新的一篇文章來講講最近踩的雷,起因手邊有個案子開了一台CentOS 8機器給我,讓我在上面設定docker跟跑起服務。實在跟CentOS很不熟的我決定寫篇備忘錄。 一開始就先開台乾淨的CentOS VM來準備被我玩爛... install centos Install Docker 然後,讓我慢慢安裝docker。