Markdown + GitHub Pages 免费搭建个人网站/博客/文档
不想花一分钱买服务器,又想要一个属于自己的网址?如果你已经在用 Markdown 写东西,GitHub Pages 几乎是门槛最低、最稳的免费建站方案。
Markdown + GitHub Pages 免費搭建個人網站/部落格/文件
不想花一分錢買伺服器,又想要一個屬於自己的網址?如果你已經在用 Markdown 寫東西,GitHub Pages 幾乎是門檻最低、最穩的免費建站方案。
Build a free personal site / blog / docs with Markdown + GitHub Pages
Don't want to spend a cent on a server, but still want a URL of your own? If you already write things in Markdown, GitHub Pages is about the lowest-friction, most reliable free hosting option.
一、GitHub Pages 是什么
GitHub Pages 是 GitHub 提供的静态网页托管服务:你把 HTML、CSS、JS 这些静态文件推到仓库,GitHub 就帮你生成一个 https://用户名.github.io 的网址,全世界都能访问。它不跑后端程序、不连数据库,所以免费、快、还不容易挂。
这对“写 Markdown 的人”特别友好——Markdown 本身就是为生成静态网页而生的,两者几乎天生一对。
二、为什么 Markdown 用户最适合
你已经有内容资产了。平时用 Markdown 记的笔记、写的教程、整理的文档,只要再走一步“渲染成网页”,就能变成公开的站点。相比从零学 HTML:
- 写作成本低:继续用你熟悉的
#标题、-列表,不用管布局。 - 版本可追溯:每次改动都进 Git 历史,误删、想回滚都有据可查。
- 纯文本好迁移:哪天想换平台,把
.md文件带走即可,不被绑定。 - 零运维:不用买服务器、配环境,GitHub 帮你托管和发 HTTPS。
小技巧:先把内容在 365Lab 在线编辑器 里写顺、预览满意,再导出或复制进仓库,效率最高。
三、三种建站方式怎么选
1. 手动上传 HTML(最简单)
直接把写好的网页文件拖进仓库。适合只想放一个简单主页或单页简历的人。缺点是要自己写/维护 HTML。
2. 静态网站生成器(最主流)
用 Jekyll、Hugo、Astro、VitePress 这类工具,你只写 Markdown,工具帮你生成整套带导航、搜索、分页的站点。其中 Jekyll 被 GitHub Pages 原生支持,配置最少。
3. 纯 Markdown 直出(极简)
有些方案(如 mdBook、MkDocs)专门把一堆 Markdown 变成文档站/电子书,几乎零配置。适合写产品文档、教程合集。
| 方式 | 上手难度 | 适合 | 是否需本地构建 |
|---|---|---|---|
| 手动 HTML | 低 | 单页主页/简历 | 否 |
| Jekyll | 中 | 博客/文档站 | 否(GitHub 构建) |
| Hugo/Astro | 中高 | 大型站点 | 是 |
| MkDocs/mdBook | 低 | 技术文档 | 是 |
四、从零搭建一个文档站
下面用“最少配置”的 Jekyll 路线演示,GitHub 会替你构建,本地无需安装 Ruby。
步骤 1:新建仓库
在 GitHub 新建一个名为 用户名.github.io 的公开仓库(用户名要和你 GitHub 账号一致),这个仓库名就是你的网址。
步骤 2:放一个 Markdown 文章
在仓库里新建 index.md,开头写一段“前置信息”(front matter),告诉 Jekyll 怎么处理:
---
title: 我的主页
layout: default
---
# 你好,这是我的站点
用 Markdown 写的内容会自动变成网页。
- 支持列表
- 支持 **加粗**
- 支持 [链接](/about)
步骤 3:加一个配置文件
新建 _config.yml,至少写一行主题:
theme: jekyll-theme-minimal
步骤 4:推送并等待
把文件推到 main 分支,GitHub 会在后台构建。一两分钟后访问 https://用户名.github.io 就能看到页面。构建状态可在仓库的 Actions 标签页查看。
注意:仓库必须是 Public(免费版),且分支设为 GitHub Pages 的发布源(默认就是 main 根目录)。
五、自定义域名与 HTTPS
不想用 github.io 结尾?可以绑定自己的域名(如 blog.你的名字.com):
- 在域名服务商处加一条
CNAME记录,指向用户名.github.io。 - 在仓库 Settings → Pages → Custom domain 填入你的域名。
- GitHub 会自动签发并续期 HTTPS 证书,免费且不用你管。
绑定后建议勾选 “Enforce HTTPS”,让所有访问都走加密连接——这也有利于搜索排名。
六、常见问题
Q:完全不懂 Git 能建吗?
A:能。GitHub 网页端可以直接新建/编辑文件、点 “Commit” 保存,不用装任何命令行工具。内容先在本地的 365Lab 编辑器 写好再粘贴最省事。
Q:GitHub Pages 收费吗?
A:公开仓库的 Pages 完全免费,带宽对个人站点足够。私有仓库也能用,但个人用途免费额度已很宽裕。
Q:能放图片和下载文件吗?
A:能。把图片放进仓库,用相对路径引用即可;具体图片写法见 Markdown 插入图片。大文件建议用图床或对象存储。
Q:和写 README 有什么关系?
A:README 也是 Markdown,很多项目的文档站就是由 README 和 /docs 下的 Markdown 自动生成的。想系统学文档写法,看 Markdown 写 GitHub README。
想先有一份可复制的文档内容?用 Markdown 导出 HTML 把稿件转成网页素材;团队一起维护文档可参考 Markdown 团队协作;新手从 Markdown 入门 起步最稳。想用生成器把一堆 Markdown 变成完整站点,看 Markdown 静态网站生成器怎么选。
一、GitHub Pages 是什麼
GitHub Pages 是 GitHub 提供的靜態網頁託管服務:你把 HTML、CSS、JS 這些靜態檔案推到倉庫,GitHub 就幫你生成一個 https://使用者名稱.github.io 的網址,全世界都能存取。它不跑後端程式、不連資料庫,所以免費、快、還不容易掛。
這對「寫 Markdown 的人」特別友好——Markdown 本身就是為生成靜態網頁而生的,兩者幾乎天生一對。
二、為什麼 Markdown 使用者最適合
你已經有內容資產了。平常用 Markdown 記的筆記、寫的教學、整理的文件的,只要再走一步「渲染成網頁」,就能變成公開的站點。相比從零學 HTML:
- 寫作成本低:繼續用你熟悉的
#標題、-清單,不用管布局。 - 版本可追溯:每次改動都進 Git 歷史,誤刪、想回滾都有據可查。
- 純文字好遷移:哪天想換平台,把
.md檔帶走即可,不被綁定。 - 零維運:不用買伺服器、配環境,GitHub 幫你託管和發 HTTPS。
小技巧:先把內容在 365Lab 線上編輯器 裡寫順、預覽滿意,再匯出或複製進倉庫,效率最高。
三、三種建站方式怎麼選
1. 手動上傳 HTML(最簡單)
直接把寫好的網頁檔拖進倉庫。適合只想放一個簡單主頁或單頁履歷的人。缺點是要自己寫/維護 HTML。
2. 靜態網站生成器(最主流)
用 Jekyll、Hugo、Astro、VitePress 這類工具,你只寫 Markdown,工具幫你生成整套帶導覽、搜尋、分頁的站點。其中 Jekyll 被 GitHub Pages 原生支援,設定最少。
3. 純 Markdown 直出(極簡)
有些方案(如 mdBook、MkDocs)專門把一堆 Markdown 變成文件站/電子書,幾乎零設定。適合寫產品文件、教學合集。
| 方式 | 上手難度 | 適合 | 是否需本地構建 |
|---|---|---|---|
| 手動 HTML | 低 | 單頁主頁/履歷 | 否 |
| Jekyll | 中 | 部落格/文件站 | 否(GitHub 構建) |
| Hugo/Astro | 中高 | 大型站點 | 是 |
| MkDocs/mdBook | 低 | 技術文件 | 是 |
四、從零搭建一個文件站
下面用「最少設定」的 Jekyll 路線示範,GitHub 會替你構建,本地無需安裝 Ruby。
步驟 1:新建倉庫
在 GitHub 新建一個名為 使用者名稱.github.io 的公開倉庫(使用者名稱要和你 GitHub 帳號一致),這個倉庫名就是你的網址。
步驟 2:放一個 Markdown 文章
在倉庫裡新建 index.md,開頭寫一段「前置資訊」(front matter),告訴 Jekyll 怎麼處理:
---
title: 我的主页
layout: default
---
# 你好,这是我的站点
用 Markdown 写的内容会自动变成网页。
- 支持列表
- 支持 **加粗**
- 支持 [链接](/about)
步驟 3:加一個設定檔
新建 _config.yml,至少寫一行主題:
theme: jekyll-theme-minimal
步驟 4:推送並等待
把檔案推到 main 分支,GitHub 會在背景構建。一兩分鐘後造訪 https://使用者名稱.github.io 就能看到頁面。構建狀態可在倉庫的 Actions 分頁查看。
注意:倉庫必須是 Public(免費版),且分支設為 GitHub Pages 的發布源(預設就是 main 根目錄)。
五、自訂網域與 HTTPS
不想用 github.io 結尾?可以綁定自己的網域(如 blog.你的名字.com):
- 在網域服務商處加一條
CNAME記錄,指向使用者名稱.github.io。 - 在倉庫 Settings → Pages → Custom domain 填入你的網域。
- GitHub 會自動簽發並續期 HTTPS 憑證,免費且不用你管。
綁定後建議勾選「Enforce HTTPS」,讓所有存取都走加密連線——這也有利於搜尋排名。
六、常見問題
Q:完全不懂 Git 能建嗎?
A:能。GitHub 網頁端可以直接新建/編輯文件、點「Commit」儲存,不用裝任何命令列工具。內容先在本地的 365Lab 編輯器 寫好再貼上最省事。
Q:GitHub Pages 收費嗎?
A:公開倉庫的 Pages 完全免費,頻寬對個人站點足夠。私有倉庫也能用,但個人用途免費額度已很寬裕。
Q:能放圖片和下載檔案嗎?
A:能。把圖片放進倉庫,用相對路徑引用即可;具體圖片寫法見 Markdown 插入圖片。大檔案建議用圖床或物件儲存。
Q:和寫 README 有什麼關係?
A:README 也是 Markdown,很多專案的文件站就是由 README 和 /docs 下的 Markdown 自動生成的。想系統學文件寫法,看 Markdown 寫 GitHub README。
想先有一份可複製的文件內容?用 Markdown 匯出 HTML 把稿件轉成網頁素材;團隊一起維護文件可參考 Markdown 團隊協作;新手從 Markdown 入門 起步最穩。想用生成器把一堆 Markdown 變成完整站點,看 Markdown 靜態網站生成器怎麼選。
1. What GitHub Pages is
GitHub Pages is a static web hosting service from GitHub: push your static files (HTML, CSS, JS) to a repo and GitHub gives you a https://username.github.io URL the whole world can visit. It runs no backend and connects to no database, so it's free, fast, and rarely goes down.
This is especially friendly to "people who write Markdown"—Markdown was born to generate static web pages, so the two are a natural pair.
2. Why Markdown users fit best
You already have a content asset. The notes, tutorials, and docs you write in Markdown only need one more step—"render to a web page"—to become a public site. Compared with learning HTML from scratch:
- Low writing cost: keep using the
#headings and-lists you know; no layout to worry about. - Traceable versions: every change lands in Git history, so deletes and rollbacks are auditable.
- Plain text migrates well: if you switch platforms someday, just take the
.mdfiles—nothing locks you in. - Zero ops: no server to buy, no environment to configure; GitHub hosts it and serves HTTPS.
Tip: Write and preview the content in the 365Lab online editor first, then export or copy it into the repo—that's the most efficient flow.
3. Three ways to build—how to choose
1. Upload HTML by hand (simplest)
Just drag your finished web files into the repo. Good for someone who only wants a simple homepage or a one-page résumé. The downside is you write/maintain the HTML yourself.
2. Static site generator (most popular)
With tools like Jekyll, Hugo, Astro, VitePress, you write only Markdown and the tool generates a full site with navigation, search, and pagination. Jekyll is natively supported by GitHub Pages, so it needs the least config.
3. Pure Markdown output (minimal)
Some options (like mdBook, MkDocs) turn a pile of Markdown into a doc site / e-book with almost zero config. Great for product docs and tutorial collections.
| Way | Difficulty | Best for | Local build needed? |
|---|---|---|---|
| Manual HTML | Low | Single-page home / résumé | No |
| Jekyll | Medium | Blog / doc site | No (GitHub builds) |
| Hugo/Astro | Medium-high | Large sites | Yes |
| MkDocs/mdBook | Low | Technical docs | Yes |
4. Build a doc site from scratch
Here's the "minimal config" Jekyll route—GitHub builds it for you, no Ruby install locally.
Step 1: Create a repo
On GitHub, create a public repo named username.github.io (the username must match your GitHub account). That repo name is your URL.
Step 2: Add a Markdown page
In the repo, create index.md and start it with some "front matter" telling Jekyll how to process it:
---
title: My homepage
layout: default
---
# Hello, this is my site
Content written in Markdown becomes a web page automatically.
- Supports lists
- Supports **bold**
- Supports [links](/about)
Step 3: Add a config file
Create _config.yml with at least one theme line:
theme: jekyll-theme-minimal
Step 4: Push and wait
Push the files to the main branch and GitHub builds in the background. A minute or two later, visit https://username.github.io to see the page. Build status is in the repo's Actions tab.
Note: The repo must be Public (free tier), and the branch must be set as the GitHub Pages publish source (by default the main root).
5. Custom domains & HTTPS
Don't want the github.io ending? You can bind your own domain (e.g. blog.yourname.com):
- At your domain registrar, add a
CNAMErecord pointing tousername.github.io. - In the repo, go to Settings → Pages → Custom domain and enter your domain.
- GitHub auto-issues and renews the HTTPS certificate for free—you don't manage it.
After binding, tick "Enforce HTTPS" so all traffic uses an encrypted connection—this also helps search ranking.
6. FAQ
Q: Can I build it with zero Git knowledge?
A: Yes. The GitHub web UI lets you create/edit files and click "Commit" to save—no command-line tools needed. Easiest is to write the content in the local 365Lab editor first, then paste it in.
Q: Does GitHub Pages cost anything?
A: Pages on public repos is completely free, with bandwidth enough for a personal site. Private repos work too, and the free allowance for personal use is already generous.
Q: Can I host images and downloadable files?
A: Yes. Put images in the repo and reference them by relative path; for the exact image syntax see Inserting images in Markdown. For large files, use an image host or object storage.
Q: How is it related to writing a README?
A: A README is also Markdown, and many projects' doc sites are auto-generated from the README and the Markdown under /docs. To learn doc authoring systematically, see Writing GitHub READMEs in Markdown.
Want a copyable doc first? Use Markdown to HTML to turn your draft into web assets; for maintaining docs as a team see Markdown for team docs & collaboration; beginners should start from Markdown basics. To turn a pile of Markdown into a full site with a generator, see how to choose a Markdown static site generator.