Onedocs

SEO & Search

Onedocs includes helpers for search, sitemaps, and AI-friendly documentation.

Onedocs uses Fumadocs' built-in Orama search. Create an API route:

src/app/api/search/route.ts
import { source } from "@/lib/source";
import { createFromSource } from "fumadocs-core/search/server";

export const { GET } = createFromSource(source);

That's it. Search works automatically with the Fumadocs UI search component.

Sitemap

Generate a sitemap at /sitemap.xml:

src/app/sitemap.ts
import { generateSitemap } from "onedocs/seo";
import meta from "../content/docs/meta.json";

const baseUrl = "https://yourdomain.com";

export default function sitemap() {
  return generateSitemap({
    baseUrl,
    pages: meta.pages ?? [],
  });
}

Robots.txt

Generate a robots.txt at /robots.txt:

src/app/robots.ts
import { generateRobots } from "onedocs/seo";

const baseUrl = "https://yourdomain.com";

export default function robots() {
  return generateRobots({ baseUrl });
}

This creates:

User-agent: *
Allow: /
Sitemap: https://yourdomain.com/sitemap.xml

LLMs.txt

LLMs.txt helps AI assistants understand your documentation. Onedocs can generate both summary and full-content versions.

Summary version

Create /llms.txt with page titles and descriptions:

src/app/llms.txt/route.ts
import { createLLMsSource, generateLLMsText } from "onedocs/llms";
import { source } from "@/lib/source";
import config from "../../../onedocs.config";

export async function GET() {
  const llmsSource = createLLMsSource(source);
  const text = await generateLLMsText(llmsSource, {
    title: config.title,
    description: config.description,
  });

  return new Response(text, {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}

Full content version

Create /llms-full.txt with complete documentation:

src/app/llms-full.txt/route.ts
import { createLLMsSource, generateLLMsFullText } from "onedocs/llms";
import { source } from "@/lib/source";

export async function GET() {
  const llmsSource = createLLMsSource(source);
  const text = await generateLLMsFullText(llmsSource);

  return new Response(text, {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}

Configuration options

Sitemap options

generateSitemap({
  baseUrl: "https://yourdomain.com",
  pages: ["index", "getting-started", "configuration"],
  docsPath: "/docs", // Default: "/docs"
});

Robots options

generateRobots({
  baseUrl: "https://yourdomain.com",
  sitemapPath: "/sitemap.xml", // Default: "/sitemap.xml"
});

What you get

After setting up these routes:

URLWhat it does
/api/search?query=...Search API endpoint
/sitemap.xmlXML sitemap for search engines
/robots.txtRobots file with sitemap reference
/llms.txtSummary for AI assistants
/llms-full.txtFull docs for AI assistants

On this page