對 AI 代理友善的網站
原則:每個 HTML 頁面都有一個內容完全相同的 Markdown 孿生頁面,且代理知道如何找到它。
python3 scripts/check_seo_agents.py 會驗證以下所有項目。
1. 每個頁面的 .md 孿生頁面
| HTML 頁面 | 檔案 | Markdown URL |
|---|---|---|
site/index.html → / | site/index.md | /index.md |
site/tutos/git-rebase/index.html → /tutos/git-rebase/ | site/tutos/git-rebase/index.md | /tutos/git-rebase/index.md |
例外:404.html (沒有孿生頁面)。
建立或修改頁面時,需在同一個 commit 中修改兩個檔案。.md 檔案不是摘要:它包含頁面所有有用的內容(文字、步驟、程式碼、連結),不包含裝飾性元素。
.md 檔案格式:
---
title: Git rebase interactif en 3 minutes
description: Réécris tes commits proprement avec git rebase -i, sans rien casser.
url: https://bytetuto.com/tutos/git-rebase/
lang: fr
updated: 2026-10-16
---
# Git rebase interactif en 3 minutes
> 用 1-2 句話直接回應:這個頁面可以學到什麼。
## 步驟
1. …
```bash
git rebase -i HEAD~3
```
## 另請參閱
- [取消一個 commit](https://bytetuto.com/tutos/annuler-commit/index.md)
影片:https://www.youtube.com/watch?v=…
規則:
- YAML 前置資料需包含
title、description、url(= HTML 的標準 URL)、lang、updated(與頁面相同)。 - 只有一個
# 標題=<h1>。##/###的階層結構與 HTML 一致。 - 使用絕對連結 (
https://bytetuto.com/…),且目標若有.md則指向.md版本。 - 程式碼放在帶有語言標記的 ``` 區塊中。不要使用純 HTML、裝飾性表情符號,或沒有文字的圖片 (
)。 - 在 HTML 的
<head>中:<link rel="alternate" type="text/markdown" href="…/index.md">。
2. /llms.txt — 給代理的內容摘要
site/llms.txt,符合 llmstxt.org 格式:# byteTuto,一個 > 引言總結網站,然後是 ## 章節,內含指向 .md 檔案的連結列表:
## Tutos
- [Git rebase interactif](https://bytetuto.com/tutos/git-rebase/index.md): 重寫自己的 commit。
每新增/刪除一個頁面時,新增/移除對應的行。次要內容放在 ## Optional 章節。
當教學數量超過約 10 篇時:另外生成 site/llms-full.txt (所有 .md 的串接)。
3. 伺服器 (已在 nginx/ 中設定)
.md以text/markdown; charset=utf-8提供服務,並加上X-Robots-Tag: noindex(避免 Google 索引到重複內容 — HTML 版本仍是唯一被索引的版本)。- 內容協商:帶有
Accept: text/markdown標頭的請求訪問/或/tutos/x/時,會直接回傳.md檔案 (HTML 回應需加上Vary: Accept標頭)。 - 測試方式:
curl -s http://localhost:8088/index.md | head curl -s -H 'Accept: text/markdown' http://localhost:8088/ | head curl -sI http://localhost:8088/index.md | grep -i content-type # text/markdown
4. 可供瀏覽代理讀取的 HTML
- 內容需存在於初始 HTML 中 (不能僅由 JavaScript 渲染)。
- 使用語意化標籤、唯一的
<main>、階層分明的標題、<ol>/<ul>列表、<pre><code class="language-…">程式碼區塊。 - 按鈕 =
<button>,連結 =<a href>;每個控制項元件都需有可存取名稱 (可見文字或aria-label)。 - 表單 (如電子報):每個欄位需有
<label for>,明確的name與autocomplete屬性,結果訊息需在 DOM 中。 - 內容不能放在需要強制互動才能顯示的元件下 (如隱藏的頁籤:內容需保留在 DOM 中)。
- JSON-LD 結構化資料需保持更新 (請參閱
site-seo):代理也會使用這些資料。
5. AI 爬蟲 (robots.txt)
專案選擇:允許 AI 爬蟲 (提升在 ChatGPT、Claude、Perplexity、Google AI 中的可見性)。未經明確決策,不得為 GPTBot、ClaudeBot、PerplexityBot、Google-Extended 等新增 Disallow 規則。請將 Sitemap: 保留在檔案底部。