<meta> 標籤置於 `
| name 值 | content 內容 | 用途 |
|---|---|---|
| `description` | 頁面摘要(≤160 字符) | **SEO 關鍵**,搜尋結果摘要顯示 |
| `keywords` | 關鍵詞列表(逗號分隔) | 舊式 SEO,現代權重極低,可省略 |
| `author` | 作者姓名/機構 | 作者資訊 |
| `generator` | 生成工具(如 WordPress 6.5) | 工具統計 |
| `viewport` | `width=device-width, initial-scale=1` | **響應式必須**,移動端視口控制 |
| `robots` | `index/noindex, follow/nofollow, all, none` | 爬蟲指令:`index,follow`(預設)、`noindex,nofollow`(隱藏頁) |
| `googlebot` | 針對 Google 爬蟲指令 | 細粒度控制 |
| `theme-color` | `#hexcolor` | 瀏覽器標籤/地址欄主題色(移動端 Chrome) |
| `csrf-token` / `csrf-param` | Token 值/參數名 | Rails/Laravel 等框架 CSRF 防護 |
| `application-name` | Web App 名稱 | PWA/桌面快捷方式標題 |
| http-equiv 值 | content 內容 | 等效 HTTP 頭 | 用途 |
|---|---|---|---|
| `Content-Type` | `text/html; charset=UTF-8` | `Content-Type: text/html; charset=UTF-8` | **聲明編碼**(HTML5 建議用 ``) |
| `Content-Language` | `zh-TW` | `Content-Language: zh-TW` | 文檔語言 |
| `Refresh` | `5; url=https://example.com` | `Refresh: 5; url=...` | **定時重導向/刷新**(慎用,體驗差) |
| `Expires` | `Mon, 12 May 2025 00:20:00 GMT` | `Expires: ...` | 緩存過期時間(**必須 GMT 格式**) |
| `Pragma` | `no-cache` | `Pragma: no-cache` | HTTP/1.0 禁用緩存(兼容舊代理) |
| `Cache-Control` | `no-store, max-age=3600` | `Cache-Control: ...` | **現代緩存控制首選**(HTTP/1.1) |
| `Set-Cookie` | `name=value; expires=...; path=/` | `Set-Cookie: ...` | 設置 Cookie(**不推薦**,應由伺服器頭設置) |
| `X-UA-Compatible` | `IE=edge` | `X-UA-Compatible: IE=edge` | 強制 IE 使用最新渲染引擎(IE 專用) |
| `Content-Security-Policy` | `default-src 'self'; script-src 'self' cdn.example.com` | `Content-Security-Policy: ...` | **CSP 防 XSS**(推薦用 HTTP 頭,meta 受限) |
| `Feature-Policy` / `Permissions-Policy` | `geolocation 'self'; camera 'none'` | 同名 HTTP 頭 | 權限策略控制 |
| `windows-target` | `_top` | — | 強制頂層窗口顯示,防框架嵌入 |
| `Page-Enter` / `Page-Exit` | `revealTrans(duration=1, transition=12)` | — | 頁面進入/離開轉場效果(**IE 專有、已廢棄**) |
<head>
<meta charset="UTF-8"> <!-- 編碼:最優先,簡潔 -->
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 響應式 -->
<meta name="description" content="頁面精準摘要,160字內"> <!-- SEO 核心 -->
<meta name="theme-color" content="#2c3e50"> <!-- 品牌色 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- 兼容舊IE -->
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate"> <!-- 動態頁禁緩存 -->
<!-- CSP、權限策略、Feature-Policy 建議改用 HTTP 響應頭設置 -->
</head>
`` 雖小,却是文檔與外部世界(瀏覽器、搜尋引擎、緩存代理、安全策略)的**關鍵協議介面**。精準配置,事半功倍。