[Lv1] SEO 基礎實作:Router 模式與 Meta Tags
在多品牌平台專案中,實作 SEO 基礎配置:Router History Mode、Meta Tags 結構與靜態頁面 SEO。
1. 面試回答主軸
- Router 模式選擇:使用 History Mode 而非 Hash Mode,提供乾淨的 URL 結構。
- Meta Tags 基礎:實作完整的 SEO meta tags,包含 Open Graph 和 Twitter Card。
- 靜態頁面 SEO:為 Landing Page 配置完整的 SEO 元素。
2. Router History Mode 配置
2.1 為什麼選擇 History Mode?
檔案位置: quasar.config.js
// 第 82 行
vueRouterMode: "history", // 使用 history 模式而非 hash 模式
SEO 優勢:
| 模式 | URL 範例 | SEO 影響 |
|---|---|---|
| Hash Mode | /#/home | ❌ 搜尋引擎較難索引 |
| History Mode | /home | ✅ 乾淨的 URL,易於索引 |
關鍵差異:
- History Mode 產生乾淨的 URL(如:
/home而非/#/home) - 搜尋引擎更容易索引和爬取
- 更好的使用者體驗和分享體驗
- 需要後端支援(避免 404 錯誤)
2.2 後端配置需求
使用 History Mode 時,需要後端配置:
# Nginx 範例
location / {
try_files $uri $uri/ /index.html;
}
這樣可以確保所有路由都回傳 index.html,由前端 Router 處理。
3. Meta Tags 基礎結構
3.1 基本 SEO Meta Tags
檔案位置: template/*/public/landingPage/index.html
<!-- 基本 Meta Tags -->
<meta charset="UTF-8" />
<title>AMUSE VIP</title>
<meta name="keywords" content="カジノ,Jackpot,オンカジ,VIP" />
<meta
name="description"
content="いつでもどこでも0秒反映。先着100名限定のVIP会員テストプログラムキャンペーン"
/>
說明:
title:頁面標題,影響搜尋結果顯示keywords:關鍵字(現代 SEO 重要性較低,但仍建議設定)description:頁面描述,會顯示在搜尋結果中