商用網站架設實務

LESSON-28 · starter

優化與部署:Cloudflare Pages 上線

你會依序完成3個本堂專屬微步驟;每一步只修改一個責任,看到結果後才進下一步。 這頁用 可觀察證據anchor 指出下一個動作。

Starter3 個小成果
Checkpoint一個核心缺口
Solution4 個差異

開始前確認

這一頁的結果:入口頁可以開啟

工作方式:先把這一階段複製到自己的工作資料夾,開啟 files/index.html,記下修改前的畫面、DOM、Console 或 Network狀態。

會用到的檔案:index.htmlstyle.cssmain.jsservices.htmlabout.htmlcontact.htmlsmoke-test.md

本堂焦點:完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收

照這個順序做

一次只做一張卡。完成後先重新整理入口,再留下證據,才進入下一張。

TODO-1

把多頁網站部署後最重要的路徑先列成清單。

目的

把多頁網站部署後最重要的路徑先列成清單。

修改檔案

smoke-test.md

程式碼位置

page routes

現在要做:請在 smoke-test.md 的「page routes」位置完成:列出首頁、services、about、contact 四個公開路徑的檢查項

貼上位置:smoke-test.md:page routes 區塊,先保留同一檔案的其他內容。

- 路徑:/、/services.html、/about.html、/contact.html 都要能開啟
- 驗收證據:在自己的工作資料夾留下這一項紀錄。

預期結果:smoke test 不只檢查首頁,四頁都有明確入口。

驗收證據:清單中的四個 URL 與實際本機頁面。

卡住時先看這裡

常見錯誤:只測根網址 200 就當成部署完成。

第一個檢查:先逐頁開啟本機入口並記錄 URL。

TODO-2

把部署前的視覺驗收轉成實際 CSS 條件。

目的

把部署前的視覺驗收轉成實際 CSS 條件。

修改檔案

style.css

程式碼位置

responsive smoke rules

現在要做:請在 style.css 的「responsive smoke rules」位置完成:補上窄版容器、focus 與可讀的按鈕狀態

貼上位置:style.cssresponsive smoke rules 區塊,先保留同一檔案的其他內容。

.page-shell { width: min(100% - 2rem, 760px); }
button:focus-visible { outline: 3px solid #f1ab2c; outline-offset: 3px; }

預期結果:390px 沒有水平捲軸,鍵盤 focus 仍清楚。

驗收證據:390px 截圖、Tab 操作與 Computed

卡住時先看這裡

常見錯誤:把 overflow hidden 當成所有溢位的修正。

第一個檢查:先檢查真正超出 viewport 的元素。

TODO-3

讓 Cloudflare Pages 上線前後有可重現的 smoke test 紀錄。

目的

Cloudflare Pages 上線前後有可重現的 smoke test 紀錄。

修改檔案

main.js

程式碼位置

smoke result

現在要做:請在 main.js 的「smoke result」位置完成:在 Console 記錄公開網址、404 與表單 mock 的驗收結果

貼上位置:main.js:smoke result 區塊,先保留同一檔案的其他內容。

status.textContent = "smoke test:四頁、資源、鍵盤與 mock 已檢查";
console.log("smoke test:四頁、資源、鍵盤與 mock 已檢查");

預期結果:Console 顯示本機 smoke test 完成,沒有正式部署動作。

驗收證據:ConsoleNetwork、四頁 URL 與 mock 表單結果。

卡住時先看這裡

常見錯誤:把本機成功誤認成 Cloudflare 公開網址成功。

第一個檢查:先確認目前 URL 是本機或公開網址,再記錄環境。

階段檔案

完整檔案收在可展開的卡片中;先完成上方微步驟,再用這裡查閱與複製。檔案位置要和目前的相對路徑一致。

開啟 starter 的可執行入口

index.html入口檔案:從這份 HTML 開始觀察本堂主題結果。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>優化與部署:Cloudflare Pages 上線</title>
<link rel="icon" href="../../../assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="site-header"><a class="brand" href="index.html">安心維護</a><nav aria-label="主要導覽"><a href="index.html">首頁</a> <a href="services.html">服務</a> <a href="about.html">關於</a> <a href="contact.html">聯絡</a></nav></header>
<main class="page-shell">
<p class="eyebrow">LESSON-28 · 完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<h1>優化與部署:Cloudflare Pages 上線</h1>
<p class="page-description">完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<!-- lesson-slot -->
<section class="result-card" aria-labelledby="result-title">
<h2 id="result-title">本堂可觀察結果</h2>
<p id="status" role="status">尚未操作,請依微步驟完成本堂練習。</p>
<button id="action" type="button">執行本堂操作</button>
</section>
</main>
<script src="main.js" defer></script>
</body>
</html>
style.css呈現層:只放本堂實作需要觀察的 CSS 規則。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

:root { font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif; color: #17324d; background: #f5f8fb; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.7; }
.site-header { width: min(100% - 2rem, 920px); margin: 1rem auto 0; padding: .75rem 0; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.site-header nav { display: flex; flex-wrap: wrap; gap: .7rem; }
.site-header a { color: #155e75; }
.page-shell { width: min(100% - 2rem, 760px); margin: 2rem auto; padding: 2rem; border: 1px solid #cbd8e4; border-radius: 20px; background: #fff; }
.eyebrow { color: #176b87; font-weight: 800; }
.page-description { color: #52657d; }
.result-card { padding: 1rem; border: 1px solid #d8e0ea; border-radius: 14px; background: #fbfdff; }
button { padding: .65rem .9rem; border: 0; border-radius: 9px; background: #176b87; color: #fff; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #f1ab2c; outline-offset: 3px; }
.status { min-height: 2rem; color: #17643d; }
/* TODO-2:請在 style.css 的「responsive smoke rules」位置完成:補上窄版容器、focus 與可讀的按鈕狀態 */
/* 尚未完成部署前的窄版與鍵盤驗收規則。 */
@media (max-width: 560px) { .site-header { align-items: flex-start; flex-direction: column; } .page-shell { margin: 1rem auto; padding: 1rem; } h1 { font-size: 1.6rem; } }
main.js行為層:處理本堂操作、狀態與 Console 驗收訊息。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

const status = document.querySelector("#status, #baseline-status");
const action = document.querySelector("#action, #baseline-action");
function showResult() {
  if (status) status.textContent = "完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收:先完成入口操作,再逐步驗收。";
  console.log("LESSON-28:入口已執行");
}
// TODO-3:請在 main.js 的「smoke result」位置完成:在 Console 記錄公開網址、404 與表單 mock 的驗收結果
// 尚未留下部署前 smoke test 結果。
if (action) action.addEventListener("click", showResult);
services.html服務頁:集中說明服務內容與方案比較。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>服務方案</title>
<link rel="icon" href="../../../assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="site-header"><a class="brand" href="index.html">安心維護</a><nav aria-label="主要導覽"><a href="index.html">首頁</a> <a href="services.html">服務</a> <a href="about.html">關於</a> <a href="contact.html">聯絡</a></nav></header>
<main class="page-shell">
<p class="eyebrow">LESSON-28 · 完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<h1>服務方案</h1>
<p class="page-description">完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<!-- lesson-slot -->
<section class="service-grid"><article class="service-card"><h2>到府諮詢</h2><p>先釐清訪客需求。</p></article><article class="service-card"><h2>定期維護</h2><p>建立穩定的服務節奏。</p></article></section>
</main>
<script src="main.js" defer></script>
</body>
</html>
about.html關於頁:說明商家背景與服務方式。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>關於商家</title>
<link rel="icon" href="../../../assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="site-header"><a class="brand" href="index.html">安心維護</a><nav aria-label="主要導覽"><a href="index.html">首頁</a> <a href="services.html">服務</a> <a href="about.html">關於</a> <a href="contact.html">聯絡</a></nav></header>
<main class="page-shell">
<p class="eyebrow">LESSON-28 · 完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<h1>關於商家</h1>
<p class="page-description">完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<!-- lesson-slot -->
<section><h2>我們如何協助</h2><p>先理解現場,再提出可執行的服務方案。</p></section>
</main>
<script src="main.js" defer></script>
</body>
</html>
contact.html聯絡頁:提供表單欄位與狀態流程。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>聯絡與諮詢</title>
<link rel="icon" href="../../../assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="site-header"><a class="brand" href="index.html">安心維護</a><nav aria-label="主要導覽"><a href="index.html">首頁</a> <a href="services.html">服務</a> <a href="about.html">關於</a> <a href="contact.html">聯絡</a></nav></header>
<main class="page-shell">
<p class="eyebrow">LESSON-28 · 完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<h1>聯絡與諮詢</h1>
<p class="page-description">完成多頁網站的 production 檢查與 Cloudflare Pages 上線驗收</p>
<!-- lesson-slot -->
<form id="contact-form"><label for="name">姓名</label><input id="name" name="name" required><label for="email">Email</label><input id="email" name="email" type="email" required><button id="action" type="submit">送出諮詢</button><p id="status" role="status">尚未送出</p></form>
</main>
<script src="main.js" defer></script>
</body>
</html>
smoke-test.md部署前檢查清單:只做本機 smoke test,不執行 Cloudflare 部署。

這段要貼在哪裡:先在自己的工作資料夾建立同名相對位置,再複製內容。

# 優化與部署:Cloudflare Pages 上線 smoke test

- [ ] 開啟首頁、services、about、contact
- [ ] 檢查 Console 與 Network
- [ ] 以 390px 檢查水平捲軸與鍵盤 focus
<!-- TODO-1:請在 smoke-test.md 的「page routes」位置完成:列出首頁、services、about、contact 四個公開路徑的檢查項 -->
<!-- 尚未列出四個多頁網站的公開路徑。 -->

完成驗收

下一步

Starter 完成後,不要直接看 Solution;先前往 Checkpoint,自己找出最後一個核心缺口。

前往 Checkpoint,自己補最後一個核心缺口