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

· Joseph · DevOps  · 2 min read

Set godaddy domain and build hugo on gitlab pages

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 »
替 n8n 接上 OIDC SSO

替 n8n 接上 OIDC SSO

需求一句話講得完: 讓 n8n 支援 OIDC SSO 登入。 這看似只是改改環境變數的小需求,但當初我和 AI 一起討論並嘗試串接時,發現真正折磨人的不是語法,而是這一路上幾乎每個坑都 不會叫: Pod 正常 、Kubernetes 健檢全綠、 指令回傳 0、Log 裡沒有半點 Error,但使用者就是登不進去。…

把三份 K8s stack 合併成單一 Helm stack

把三份 K8s stack 合併成單一 Helm stack

起點與多份副本的維護問題 我們的 K8s 部署原本是三份平行的 stack:nvidia、amd、arm64 各一份。維護規則寫在 裡,只有一句話: 改一份要同步三份。 這條規則的問題不在於它難懂,而在於它把一致性外包給人的紀律。實際的腐化程度可以量:舊的 在三份副本之間有高達七成以上的內容完全分岔。這已經不是「三份…

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, a…