Robots 與 Indexability|Nuxt SEO
robots.txt 控制搜尋引擎的抓取範圍,Indexability Matrix 定義哪些頁面該被索引、哪些不該。PWA offline fallback 則是容易被忽略的 SEO 風險。三者必須互相一致,不能出現 robots 擋了但 sitemap 放了、或 offline 頁被索引的矛盾。
Robots.txt SOP
Production 必須允許抓取
Production 的 robots.txt 不得留下開發期的全站封鎖:
# ❌ 這會讓 Google 完全無法抓取User-agent: *Disallow: /Nuxt 設定範例
robots: { rules: [ { UserAgent: '*', Allow: '/' }, { UserAgent: '*', Disallow: '/api' }, { UserAgent: '*', Disallow: '/account' }, { UserAgent: '*', Disallow: '/history' }, { UserAgent: '*', Disallow: '/payment' }, { UserAgent: '*', Disallow: '/checkout' }, { UserAgent: '*', Disallow: '/console' } ], sitemap: 'https://www.example.com/sitemap_index.xml'}Robots 檢查清單
- production
robots.txt回200,Content-Type 是text/plain。 - production 允許抓公開頁。
- staging / preview 可視需求
Disallow: /,但不得污染 production。 - robots 中 Sitemap URL 使用 canonical domain。
- 被 robots 擋的頁面不在 sitemap 中。
Indexability Matrix
應索引的頁面
//pricing//guide/、/guide/**/cards/、/cards/**/learn/、/learn/**- 公開文章、知識庫、教學頁
- 對應存在的
/ja/**、/en/**公開頁
不應索引的頁面
/offline/history/**/account/**/login、/register/auth/**/payment/**、/payment/result、/payment-success/checkout/**/credits/**/console/api/**- webhook、callback、後台、會員資料頁
不可出現的矛盾
以下任一種情況都是 P0 問題,必須立刻修:
- sitemap 包含 noindex 頁
- sitemap 包含 robots blocked 頁
- sitemap URL 回 3xx / 4xx
- canonical 指向另一個語系或另一個網域
- SSR HTML 是「找不到文章」,但 sitemap 說它是可索引頁
- 使用者直接貼連結進站看到 offline,但站內點擊正常
PWA / Offline Fallback SEO 風險
若使用 @vite-pwa/nuxt,要特別小心 navigateFallback:
workbox: { navigateFallback: '/offline'}這會讓被 service worker 控制的瀏覽器,在硬導頁、貼網址、重新整理、外部分享進站時,可能拿到 /offline。站內 <NuxtLink> 是 client-side navigation 所以可能正常,問題很難被開發者發現。
PWA SEO 原則
/offline必須noindex, nofollow。/offline不得進 sitemap。- 公開 SEO 頁不應被 service worker fallback 成 offline。
- 文章頁、知識庫頁、價格頁、法務頁、首頁等公開頁應加入
navigateFallbackDenylist。
設定範例
pwa: { registerType: 'prompt', workbox: { navigateFallback: '/offline', navigateFallbackDenylist: [ /^\/$/, /^\/api\//, /^\/auth\//, /^\/account/, /^\/history/, /^\/payment/, /^\/checkout/, /^\/cards(?:\/|$)/, /^\/learn(?:\/|$)/, /^\/guide(?:\/|$)/, /^\/pricing(?:\/|$)/, /^\/legal(?:\/|$)/, /^\/(?:ja|en)(?:\/(?:cards|learn|guide|pricing|legal)(?:\/|$)|\/?$)/ ] }}PWA 測試方式
- 無痕視窗直接貼公開內容 URL。
- 一般視窗已註冊 service worker 後直接貼公開內容 URL。
- Chrome DevTools → Application → Service Workers 檢查 SW 是否更新。
- 部署 PWA 修正後,提醒使用者 hard reload 或等 update banner 觸發。
驗證指令
確認 production 允許抓取
Robots 檢查
curl -I https://www.example.com/robots.txtcurl -L https://www.example.com/robots.txt確認 sitemap 不含禁止頁面
Indexability 矛盾檢查
# sitemap 不應包含這些路由curl -L https://www.example.com/__sitemap__/zh-TW.xml \ | grep -E "/offline|/payment|/account|/history|/login|/register|/api/"完成標準
Checklist
Robots / Indexability / PWA 檢查
- production robots.txt 200,允許抓取公開頁
- robots Sitemap URL 使用 canonical domain
- 被 robots 擋的頁面不在 sitemap
- sitemap 不含 noindex 頁
-
/offline有 noindex/nofollow -
/offline不在 sitemap - 公開 SEO 頁在 PWA navigateFallbackDenylist
- 無痕視窗直接貼公開 URL 不進 offline