Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

如何正確設定 WordPress 的 robots.txt 與 Sitemap(以 SureRank 為例)

Posted on 2025-11-052025-11-05 by Rico

在網站 SEO 優化的過程中,常聽到兩個關鍵字:robots.txt 與 sitemap.xml。
這兩個檔案雖然簡單,卻是影響搜尋引擎能否順利索引網站內容的重要關鍵。
本文以實際案例(網站:https://www.nuface.tw/、使用 WordPress 6.8.3 + SureRank SEO Plugin)說明設定方式與常見錯誤排除方法。


一、robots.txt 是什麼?

robots.txt 是放在網站根目錄下的文字檔,用來告訴搜尋引擎哪些內容可以被爬取(crawl),哪些不行。
這個檔案不會影響網站運作,但會影響 Google、Bing 等搜尋引擎的收錄行為。

📂 位置:

https://www.你的網域/robots.txt

🧱 功能:

  • 限制搜尋引擎存取網站內特定資料夾(例如 /wp-admin/、/tmp/)
  • 引導搜尋引擎找到 Sitemap
  • 降低伺服器負擔,避免無用頁面被索引

二、WordPress 建議版 robots.txt

若你的網站使用 WordPress(例如 SureRank、Yoast、Rank Math 等 SEO 外掛),
建議使用以下設定:

# =====================================================
# robots.txt for https://www.nuface.tw/
# WordPress 6.8.3 + SureRank SEO Plugin
# =====================================================

User-agent: *
# 禁止搜尋引擎爬取 WordPress 系統目錄
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/cache/
Disallow: /wp-content/themes/

# 禁止搜尋無意義頁面
Disallow: /?s=
Disallow: /search
Disallow: /cgi-bin/
Disallow: /trackback/
Disallow: /xmlrpc.php
Disallow: /readme.html
Disallow: /?replytocom
Disallow: /wp-login.php
Disallow: /wp-register.php

# 允許後台 AJAX(WordPress 需要)
Allow: /wp-admin/admin-ajax.php

# 指定 SureRank 產生之 Sitemap Index
Sitemap: https://www.nuface.tw/sitemap_index.xml

# =====================================================
# Notes:
# 搜尋引擎會自動解析 sitemap_index.xml 裡的所有子 sitemap。
# =====================================================

三、SureRank Sitemap 設定說明

SureRank 會自動產生一個「索引型 Sitemap(sitemap index)」:
👉 https://www.nuface.tw/sitemap_index.xml

此檔案內包含多個子 sitemap,例如:

https://www.nuface.tw/post-type-page-sitemap-1.xml
https://www.nuface.tw/post-type-post-sitemap-1.xml
https://www.nuface.tw/post-type-sureforms_form-sitemap-1.xml
https://www.nuface.tw/taxonomy-type-category-sitemap-1.xml

搜尋引擎只需讀取最上層的 sitemap_index.xml,
即可自動遞迴讀取下層 sitemap,因此在 robots.txt 中只需列出一行即可。


四、常見錯誤:首頁無法被索引(Homepage not indexable)

在 SureRank 的 Site Analysis 中,有時會看到如下警示訊息:

⚠️ Homepage is not indexable by search engines

這代表搜尋引擎目前被阻擋,無法將首頁列入搜尋結果。
造成這種狀況的原因常有以下幾種:

問題原因解決方式
WordPress 啟用了「阻止搜尋引擎索引本站」進入 設定 → 閱讀,取消勾選「阻止搜尋引擎索引本站」。
SureRank 外掛首頁設定為 noindex編輯首頁頁面 → SureRank → 進階設定,確認 Meta Robots 設為 Index。
robots.txt 設錯(出現 Disallow: /)檢查 robots.txt,移除 Disallow: /。
主題或外掛自動插入 noindex 標籤檢查頁面原始碼,確認 <meta name="robots" content="noindex"> 不存在。

五、修正後檢查與驗證

  1. 重新提交 Sitemap:
    前往 Google Search Console,在「Sitemaps」區輸入: sitemap_index.xml
  2. 搜尋確認:
    在 Google 搜尋列輸入: site:nuface.tw 若能看到首頁出現在搜尋結果中,代表設定正確。
  3. 持續觀察:
    搜尋引擎通常需 1–3 天重新抓取、更新索引。

六、結語

正確設定 robots.txt 與 sitemap.xml,是讓搜尋引擎順利理解網站結構的第一步。
建議在每次網站更新或更換主題後,都重新檢查:

  • robots.txt 是否仍允許索引
  • Sitemap 是否可正常開啟
  • 首頁沒有被標示為 noindex

當設定正確後,SureRank 會協助 Google、Bing 更快速地收錄網站內容,
確保你的品牌與文章能穩定出現在搜尋結果中。


作者註:
本教學以 https://www.nuface.tw/ 實際設定為例,
適用於所有使用 WordPress + SureRank SEO Plugin 的網站管理者。


Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme