Home首頁  /  Lessons課程  /  Lesson 4第四課

Get Your Own Domain擁有你自己的網域

Right now your site lives at a long username.github.io address. A custom domain — like ai-for-teachers.org — is short, professional, and truly yours. This lesson shows you how to buy one and point it at your GitHub site.

現在你的網站住在一長串的 username.github.io 網址。一個自訂網域——像 ai-for-teachers.org——又短、又專業、而且真正屬於你。這一課教你怎麼買一個,並把它指向你的 GitHub 網站。

What you'll understand你會明白

  • a Why a custom domain is worth it — and what it costsa 自訂網域值不值得——以及要花多少錢
  • b Where to buy it — registrars comparedb 去哪買——各家網域公司比較
  • c How to point DNS at your GitHub Pages sitec 怎麼把 DNS 指向你的 GitHub Pages 網站
  • d Connecting it in GitHub and turning on HTTPSd 在 GitHub 接上網域並開啟 HTTPS
The basics基本觀念

What a domain is, and what it costs網域是什麼,要花多少錢

A domain is your web address. You don't buy it once — you rent it yearly, usually about US$10–12 a year for a .com or .org.網域就是你的網址。它不是一次買斷——你是按年租用,.com.org 通常一年約 US$10–12。

Where to buy去哪買

Registrars compared各家網域公司比較

A registrar is the company you buy from. They're not all equal — here are the popular ones:Registrar(網域註冊商)就是你買網域的公司。各家差很多——以下是常見的幾家:

Registrar註冊商 Why people like it優點 Watch out for要注意
Cloudflare At-cost pricing (cheapest), free privacy, excellent DNS成本價(最便宜)、免費隱私保護、DNS 很強 Fewer TLDs; must use Cloudflare's DNS; plainer interfaceTLD 較少;必須用 Cloudflare 的 DNS;介面樸素
Namecheap Affordable, friendly, lots of TLDs, free privacy便宜、好上手、TLD 多、免費隱私 A few upsells at checkout結帳時會推銷一些加購
Porkbun Low prices, lovely interface, many TLDs, free privacy價格低、介面好用、TLD 多、免費隱私 Smaller name (but solid and trusted)名氣較小(但穩定可靠)
Squarespace Simple; took over Google Domains簡單;接手了 Google Domains Mid-priced; tied to the Squarespace ecosystem價格中等;綁在 Squarespace 生態
GoDaddy Huge, cheap first year, ads everywhere規模大、第一年便宜、到處打廣告 Pushy upsells; renewals get pricey — read the renewal price推銷很兇;續約變貴——務必看清續約價
My pick:我的建議: for best value, Cloudflare (it's what this whole site uses). Want the friendliest experience? Namecheap or Porkbun. Whatever you choose, check the renewal price and turn on free privacy. 想要最划算就用 Cloudflare(這整個網站就是用它)。想要最好上手?NamecheapPorkbun。不管選哪家,都記得看續約價、開免費隱私保護。
Step by step一步一步

Buying your domain買下你的網域

  1. Search for a name搜尋名稱 Pick something short and easy to say. If the short one is taken, try the spelled-out version (e.g. ai-for-teachers.org).挑一個短又好唸的。短的被搶走了,就試把字拼出來的版本(例如 ai-for-teachers.org)。
  2. Check both prices看兩個價格 The first-year price and the renewal price.第一年價 續約價都要看。
  3. Register and pay註冊並付款 Make an account and pay — usually around US$10.開個帳號、付款——通常約 US$10。
  4. Turn on privacy開啟隱私保護 Free WHOIS privacy hides your home address and email from public records.免費的 WHOIS 隱私保護會把你的住址和 email 從公開資料裡藏起來。
  5. Turn on auto-renew開啟自動續約 So you never accidentally lose your domain.這樣才不會不小心讓網域過期被收回。
Point it at GitHub指向 GitHub

Setting up DNS設定 DNS

DNS is the internet's address book — it tells the world where your domain should go. To point it at your GitHub Pages site, add a few records in your registrar's DNS settings.DNS 是網際網路的「通訊錄」——它告訴全世界你的網域該連到哪。要把它指向 GitHub Pages,就在註冊商的 DNS 設定裡加幾筆記錄。

  1. Add 4 A records for @ (the root)@(根網域)加 4 筆 A 記錄 Point them at GitHub's four addresses:指向 GitHub 的四個位址:
    185.199.108.153
    185.199.109.153
    185.199.110.153
    185.199.111.153
  2. Add a CNAME for wwwwww 加一筆 CNAME Name www → value your-username.github.io名稱 www → 值 your-username.github.io
  3. On Cloudflare? Set them to "DNS only"用 Cloudflare?切成「DNS only」 Switch the cloud icon to grey (DNS only), so GitHub can issue your HTTPS certificate.把雲朵圖示切成灰色(DNS only),這樣 GitHub 才能簽你的 HTTPS 憑證。
A brand-new domain can take 15 minutes to a couple of hours to switch on across the internet. If nothing works yet, that's normal — wait, don't redo it. 剛註冊的新網域,可能要 15 分鐘到一兩個小時才會在全網路上線。如果還沒通,那很正常——等就好,別重做。
Connect & secure接上並上鎖

Finish in GitHub在 GitHub 完成

  1. Set the custom domain設定自訂網域 In your repo: Settings → Pages → Custom domain, type your domain, and click Save.在你的 repo:Settings → Pages → Custom domain,輸入你的網域,按 Save
  2. Let GitHub check the DNS讓 GitHub 檢查 DNS A green tick appears once it's happy with your records.記錄沒問題後,會出現綠色勾勾。
  3. Wait for the HTTPS certificate等 HTTPS 憑證 GitHub issues a free certificate automatically — it takes a few minutes.GitHub 會自動簽一張免費憑證——需要幾分鐘。
  4. Tick "Enforce HTTPS"勾選「Enforce HTTPS」 Once the certificate is ready. Your site now lives at https://yourdomain.org.等憑證好了再勾。你的網站現在就在 https://yourdomain.org 了。
Tip:小訣竅: don't tick "Enforce HTTPS" until the certificate is ready, or you'll see a warning. Give it a few minutes. 憑證還沒好之前別急著勾「Enforce HTTPS」,否則會跳警告。等個幾分鐘就好。

Quick recap快速回顧

  • A domain is a yearly rental — check first-year AND renewal price網域是按年租——第一年價和續約價都要看
  • Cloudflare = best value; Namecheap / Porkbun = friendliest; mind GoDaddy renewalsCloudflare 最划算;Namecheap/Porkbun 最好上手;當心 GoDaddy 續約價
  • Turn on free privacy + auto-renew開啟免費隱私保護 + 自動續約
  • Point the root with 4 A records → GitHub; www with a CNAME根網域用 4 筆 A 記錄 → GitHub;www 用 CNAME
  • New domains take a bit to go live — be patient新網域要一點時間上線——耐心等
  • Set the domain in GitHub Pages, then enforce HTTPS once the cert is ready在 GitHub Pages 設好網域,憑證好了再開強制 HTTPS