Building a Markdig Extension for DocFX: Remote Content Inclusion with AI Rewriting The article describes **docfx-remote-include**, a Markdig extension and CLI tool that adds remote content fetching and inlining capabilities to DocFX, Microsoft's open-source documentation generator. It allows users to include content from external sources at build time using a `[!remoteinclude]` syntax, with optional AI-powered rewriting via a pluggable `IRewriteService` to adapt the fetched content's tone and style. The tool integrates through DocFX's public `ConfigureMarkdig` extension point, supports various authentication modes, and includes safety features like recursion limits and error handling. If you've worked on a documentation platform at any scale, you've hit this problem: content lives in multiple places, and you need to compose it into a single, coherent site at build time. Maybe your API reference is generated from code. Maybe your troubleshooting guides live in a separate service. Maybe different teams own different sections, and you need to pull them together into one DocFX site without copy-pasting content that goes stale the moment it's duplicated. DocFX — Microsoft's open-source documentation generator — is excellent at building static documentation from local markdown files. But it doesn't natively support fetching and inlining content from remote sources at build time. I needed exactly that capability. So I built it. docfx-remote-include is a standalone Markdig extension and CLI tool that adds remote content inclusion to DocFX. It's not a fork of DocFX. It hooks into DocFX's public BuildOptions.ConfigureMarkdig extension point, so it tracks upstream releases as a regular NuGet dependency. When DocFX updates, your remote include capability doesn't break. In any markdown file processed by DocFX, you can write: Some local content. remoteinclude Welcome path/to/snippet.md More local content. At build time, the extension fetches {baseUrl}/path/to/snippet.md via HTTP, parses the response as markdown, and inlines the result. It works in two modes: