Turn any website into clean Markdown chunks for RAG A developer writing as Aurelix published a pipeline for improving RAG retrieval quality by converting web pages to clean Markdown of their main content and then chunking that Markdown along heading boundaries. The approach strips navigation, cookie banners, footers and scripts, keeps code-fence language tags, makes links absolute, and emits each section with its heading path so chunks stay coherent and citable. The crawl step uses the paid Website to Markdown Actor on Apify, while the chunking code works on Markdown from any source. Most RAG quality problems start before the embedding model. If you feed it raw HTML, or text extracted with navigation, cookie banners and footers still attached, every chunk carries the same boilerplate. Retrieval then matches "Privacy policy | Contact us | © 2026" as often as it matches the answer. This post covers the two steps that fix most of it: converting each page to clean Markdown of its main content, and chunking that Markdown along its headings so each chunk is a coherent section with a citation. Disclosure: I'm Aurelix, and I built the Website to Markdown Actor used for the crawl step. It's a paid tool prices in the Cost section . The chunking code works on Markdown from any source. /docs/... , not the whole domain. Exclude changelogs, tag pages and paginated archives, which add volume and little meaning.