Workflow pattern / Knowledge base
Turn a documentation site into a RAG knowledge base
Crawl a documentation set, clean it, chunk it on structure, and keep it current without rebuilding from scratch.
Intermediate / Markdown / Weekly
The problem
Support and in-product assistants answer from stale or partial documentation because nobody owns the ingest pipeline.
Who it is for
Platform teams building assistants over their own or a vendor's docs.
Teams: Platform / Documentation / Support
Inputs
- Documentation root URL
- Sitemap where available
- Version and locale rules
- Exclusion path list
Conceptual process
01Discover
Start from the sitemap, fall back to link following within the documented path scope.
02Scope
Apply include/exclude rules for versions, locales, and changelog archives.
03Deduplicate
Respect canonical tags and collapse near-identical version pages.
04Clean
Strip navigation and chrome while explicitly protecting code blocks and tables.
05Chunk
Split on headings; carry title and section path into every chunk.
06Test
Run a fixed retrieval question set and review what comes back.
07Maintain
Recrawl on a cadence, delete removed pages, and record last-retrieved per document.
Flow diagram
- 01Sitemap
- 02Scoped crawl
- 03Dedupe
- 04Normalize
- 05Chunk
- 06Index
- 07Retrieval test
Example output
{ "id": "docs/auth/api-keys#rotation", "title": "Rotating API keys", "section_path": ["Authentication", "API keys", "Rotation"], "canonical_url": "https://example.com/docs/auth/api-keys", "version": "v2", "content": "## Rotation\nKeys can be rotated without downtime by ...", "retrieved_at": "2026-09-14T09:41:00Z"}Data-quality considerations
- One H1 per page; if a template repeats the site name as H1, fix it in normalization.
- Never index pages that are pure navigation.
- Keep version as a filterable field rather than mixing versions in one index.
Failure modes
- Locale duplicates inflate the index and dilute retrieval.
- Code blocks stripped by aggressive readability extraction.
- Deleted pages remain retrievable months after removal.
- Chunks split mid-procedure, so a retrieved step loses its prerequisites.
Suggested architecture
- Sitemap reader plus scoped crawler
- Canonical-aware dedupe stage
- Normalizer with protected-element rules
- Structure-aware chunker
- Index writer with delete-on-removal
- Scheduled recrawl with a retrieval regression set
What to test first
- 01Retrieve answers for the ten questions support actually receives.
- 02Confirm a deliberately removed page disappears after one recrawl.
- 03Check that a code-heavy page keeps every code block.
Related reading
How to Crawl Documentation for RAG
Turn product documentation into a useful, maintainable knowledge source.
How to Turn a Website Into LLM-Ready Markdown
Why clean, structured text often matters more than raw HTML in AI workflows.
How to Build a Website-to-Knowledge-Base Pipeline
One ingest path, many sources: standardising how external content enters internal systems.