開發歷程:把整個網站變成 AI 讀得懂的知識包(OKF)

這是 LocalPapa Notes 開發紀錄系列的第十二篇,也是我醞釀好幾篇、終於寫到的一條長線——OKF 知識包。有趣的是:你正在讀的這個部落格,骨子裡用的就是和 OKF 一模一樣的做法。等下會說到。

問題:AI 讀網站,讀得很辛苦

當一個 AI agent 想了解「LocalPapa 有哪些工具、各自做什麼」,它得去抓你的網頁 HTML。但那份 HTML 裡塞滿了導覽列、廣告、樣式、追蹤碼——真正的「知識」只佔一小部分,其餘都是雜訊。

2026 年,Google Cloud 發佈了 OKF(Open Knowledge Format)v0.1:一個極簡的開放格式——一疊 Markdown + YAML frontmatter 的檔案。它的主張很簡單:把組織的知識打包成乾淨、可互連、AI 不必解析版型就能直接讀的 Markdown 地圖。

於是我們替 LocalPapa 建了一個 /okf/ 知識包,外加根目錄的 llms.txt 當 AI 入口。

不手刻——用生成器自動產生

最重要的決定:絕不手寫那 50 個 Markdown 檔。

工具有 38 個、會一直增加;手刻不只累,還必然會跟頁面內容對不上。所以我們寫了 scripts/build_okf.py,從既有資產自動萃取:

  • 分類與工具歸屬:解析 index.html 裡的 tool-categorytool-card
  • 各工具的英文內容:用 regex 從每個工具頁的 _toolTranslations'en' 區塊,抽出標題、副標題、操作步驟、FAQ(含反斜線跳脫的處理)。
  • canonical 網址:取各頁的 <link rel="canonical">
  • 相關工具:取 .related-card 的 href,轉成 ./slug.md 的相對連結。

新增一個工具?重跑生成器就好,知識包自動同步。這就是「單一真實來源」——內容只活在工具頁裡一份,OKF 是它的投影。

把知識變成一張「圖」

OKF 不只是一堆散檔,而是一張知識圖譜。每個工具一個 .md,frontmatter 帶 type(OKF 唯一必填欄位)加上 title/description/resource/category/tags/timestamp;內文是 How-to/FAQ/Related。

關鍵在連結:分類檔連到它的工具、工具連回分類、root 連到兩個索引——總共 338 條相對連結互相串成一張圖(生成後驗證 0 斷鏈)。AI agent 可以像走地圖一樣,從任一節點導航到全站。

有個小細節值得記:timestamp固定的建置日期,而不是「當下時間」。否則每次重跑內容都變,--check 的冪等驗證就過不了。可重現,是生成器的基本要求。

一個會吃掉成果的坑:Jekyll

這裡踩到一個 GitHub Pages 的經典坑。Pages 預設會跑 Jekyll,而 Jekyll 看到 .md自動把它轉成 HTML,並吃掉 YAML frontmatter——那正是 OKF 最重要的部分。

解法只有一個字:在 repo 根目錄放一個空的 .nojekyll 檔案。它告訴 Pages「別跑 Jekyll」,於是 /okf/**.md 就能以原始 Markdown(含 frontmatter)被服務。一個 0 byte 的檔案,決定了整個知識包成不成立。

三條入口並存,互補不取代

我們沒有用 OKF 取代既有的東西,而是讓它和其他「給機器看的」格式並存:

  • llms.txt(根目錄):AI 入口,列出工具、指向 OKF 知識包。
  • robots.txt:加註指引。
  • index.html:加 rel="alternate" type="text/markdown" 提示。
  • 既有的 schema.org JSON-LD 繼續留著。

OKF、llms.txt、JSON-LD 各服務不同的讀者,三者並存。

誠實說:這是一筆前瞻投資

這裡得老實講——OKF 今天不會幫你帶來流量。 規範很新、採用者還少,AI 引用它的情況也尚未普及。

那為什麼做?因為它的成本極低(自動產生、新增工具重跑即同步),而方向是對的:AI 搜尋與 GEO(生成式引擎優化)正在成形,「讓 agent 能直接讀懂你的網站」遲早會是基本功。這是一筆面向未來、低成本、不賭命的前瞻投資——我們也如實認知它的短期 ROI 有限。公開建造,連「這東西現在還沒回報」都該講清楚。

然後,你正在讀的這個部落格……

繞回開頭。LocalPapa Notes 用的,就是 OKF 的同一套哲學。

每篇文章是一個 Markdown 檔,一支 build_blog.py 生成器把它變成站點同風格的 HTML、列表頁與 RSS。新增文章只要丟一個 .md 再重跑——跟 OKF「新增工具就重跑」一模一樣。Markdown 當單一真實來源、生成器負責投影、--check 保證冪等:這個模式一旦驗證有效,就會在專案裡不斷複用。

OKF 不只是一個功能,它讓我們把「內容與呈現分離、用生成器連接」這件事,變成了一種團隊習慣。

學到的事

  • 別讓 AI 替你解析 HTML——主動給它乾淨的知識。 OKF/llms.txt 就是這個主動。
  • 能自動產生的,絕不手刻。 38 個工具、338 條連結,靠生成器才維護得動。
  • 冪等是生成器的命脈。 固定 timestamp、--check 驗證,讓「重跑」永遠安全。
  • 一個 0 byte 的 .nojekyll,可能就是成敗關鍵。 平台的預設行為,要先搞懂。
  • 前瞻投資要誠實標示。 低成本、面向未來、但短期沒回報——三件事都要講。

一以貫之的問題

前面十一篇問的是「能不能在瀏覽器完成」。這一篇換了個對象問:當讀者不再只是人,而是 AI agent,我們的網站準備好被『讀懂』了嗎?

我們的答案是:用一支生成器,把整站知識變成 agent 走得進來的地圖。

下一篇開發紀錄,我們會走進一個全新的大領域——把命理玄學做成 100% 瀏覽器本地、誠實標示的服務(從紫微斗數開始)。想追蹤系列?把 LocalPapa Notes 加入書籤吧。

Dev Log: Turning the Whole Site into a Knowledge Pack AI Can Read (OKF)

This is the twelfth post in the LocalPapa Notes dev-log series, and a long thread I've been brewing for several posts — the OKF knowledge pack. The fun part: this very blog is built, at heart, the exact same way as OKF. More on that below.

The problem: AI reads websites the hard way

When an AI agent wants to understand "what tools does LocalPapa have, and what does each do," it has to fetch your page's HTML. But that HTML is stuffed with navbars, ads, styles, tracking code — the actual "knowledge" is a small fraction; the rest is noise.

In 2026, Google Cloud released OKF (Open Knowledge Format) v0.1: a minimal open format — a stack of Markdown + YAML frontmatter files. Its claim is simple: pack an organisation's knowledge into a clean, interconnected Markdown map that AI can read directly, without parsing layout.

So we built LocalPapa a /okf/ knowledge pack, plus a root llms.txt as the AI entry point.

Don't hand-write — generate it

The most important decision: never hand-write those 50 Markdown files.

There are 38 tools, and the count keeps growing; hand-crafting is not only tedious but guaranteed to drift out of sync with the pages. So we wrote scripts/build_okf.py to extract automatically from existing assets:

  • Categories and tool membership: parse tool-category and tool-card in index.html.
  • Each tool's English content: regex out the title, subtitle, steps and FAQs from the 'en' block of each tool page's _toolTranslations (handling backslash escapes).
  • Canonical URL: from each page's <link rel="canonical">.
  • Related tools: from .related-card hrefs, converted into ./slug.md relative links.

Add a tool? Just re-run the generator and the pack syncs itself. That's "single source of truth" — the content lives once, in the tool pages, and OKF is its projection.

Turning knowledge into a "graph"

OKF isn't just loose files — it's a knowledge graph. One .md per tool, frontmatter carrying type (OKF's only required field) plus title/description/resource/category/tags/timestamp; the body is How-to/FAQ/Related.

The key is the links: category files link to their tools, tools link back to categories, the root links to two indexes — 338 relative links woven into a graph in total (verified with 0 broken links after generation). An AI agent can navigate the whole site from any node, like walking a map.

One detail worth noting: timestamp uses a fixed build date, not "now." Otherwise content changes on every re-run and the --check idempotency test fails. Reproducibility is a baseline requirement for a generator.

A pit that eats your output: Jekyll

Here we hit a classic GitHub Pages pit. Pages runs Jekyll by default, and Jekyll, seeing a .md, auto-converts it to HTML and eats the YAML frontmatter — which is exactly OKF's most important part.

The fix is one word: put an empty .nojekyll file at the repo root. It tells Pages "don't run Jekyll," so /okf/**.md is served as raw Markdown (frontmatter included). A 0-byte file decides whether the whole knowledge pack stands.

Three entry points coexisting, complementing not replacing

We didn't use OKF to replace what existed; we let it coexist with the other "machine-facing" formats:

  • llms.txt (root): the AI entry point, listing tools and pointing to the OKF pack.
  • robots.txt: an added pointer note.
  • index.html: a rel="alternate" type="text/markdown" hint.
  • The existing schema.org JSON-LD stays.

OKF, llms.txt and JSON-LD each serve different readers; all three coexist.

Honestly: this is a forward-looking bet

Let's be straight — OKF won't bring you traffic today. The spec is new, adopters are few, and AI citing it isn't yet common.

So why do it? Because its cost is tiny (auto-generated, re-run to sync on new tools) and the direction is right: AI search and GEO (generative engine optimisation) are taking shape, and "letting agents read your site directly" will sooner or later be table stakes. It's a forward-looking, low-cost, no-bet-the-farm investment — and we honestly acknowledge its limited short-term ROI. Building in public means stating even "this hasn't paid off yet" clearly.

And then, this blog you're reading…

Back to the opening. LocalPapa Notes uses the exact same philosophy as OKF.

Each post is a Markdown file, and a build_blog.py generator turns it into site-consistent HTML, a listing page and an RSS feed. Adding a post means dropping in a .md and re-running — identical to OKF's "add a tool, re-run." Markdown as single source of truth, the generator does the projection, --check guarantees idempotency: once this pattern proved itself, it gets reused across the project again and again.

OKF isn't just a feature; it turned "separate content from presentation, connect them with a generator" into a team habit.

What we learned

  • Don't make AI parse your HTML — proactively hand it clean knowledge. OKF/llms.txt is that proactivity.
  • Whatever can be generated, never hand-craft. 38 tools, 338 links — only a generator keeps it maintainable.
  • Idempotency is a generator's lifeblood. A fixed timestamp and --check make "re-run" always safe.
  • A 0-byte .nojekyll can be the make-or-break. Understand the platform's default behaviour first.
  • Label forward-looking bets honestly. Low-cost, future-facing, but no near-term return — say all three.

The same question, a new audience

The previous eleven posts asked "can this be done in the browser." This one asks a different audience: when the reader is no longer just a human but an AI agent, is our site ready to be "understood"?

Our answer: use one generator to turn the whole site's knowledge into a map an agent can walk into.

In the next dev log, we step into a whole new domain — building metaphysics/divination as 100% browser-local, honestly-labelled services (starting with Zi Wei Dou Shu). Want to follow the series? Bookmark LocalPapa Notes.

探索 39+ 個隱私優先的瀏覽器工具
全程本地運算、檔案不上傳。
前往 LocalPapa →
Explore 39+ privacy-first browser tools
Everything runs locally — your files never leave your device.
Visit LocalPapa →

想看英文版?點右上角 EN 切換語言。

Prefer Chinese? Tap at the top-right to switch.