SEO & Search
Onedocs includes helpers for search, sitemaps, and AI-friendly documentation.
Search
Onedocs uses Fumadocs' built-in Orama search. Create an API route:
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:
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:
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.xmlLLMs.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:
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:
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:
| URL | What it does |
|---|---|
/api/search?query=... | Search API endpoint |
/sitemap.xml | XML sitemap for search engines |
/robots.txt | Robots file with sitemap reference |
/llms.txt | Summary for AI assistants |
/llms-full.txt | Full docs for AI assistants |