Genereate LLMs.txt for your Astro site
Vinci Rufus

Vinci Rufus @areai51

About: A seasoned technology leader and AI engineer with over 25 years of experience, is currently pioneering the development of an enterprise-grade Agentic Platform

Location:
London
Joined:
Feb 28, 2019

Genereate LLMs.txt for your Astro site

Publish Date: May 8
0 0

Llms.txt are now becoming the standard way to help AI chatbots like ChatGPT, and Perplexity to easily find your content.

The easiest way to generate this file in your astro project is by creating a pages/llms.txt file with the following content

import { getCollection } from "astro:content";
import type { APIRoute } from "astro";

export const GET: APIRoute = async () => {
    const posts = await getCollection("blog"); // adjust "blog" to your collection name
    const content = `# Vinci Rufus Blog\n
    ${posts
            .map(
                (post) =>
                    `# ${post.data.title}\n\n
                https://www.vincirufus.com/postss/${post.slug}.md \n
                ${post.data.description} \n
                  ${post.body}
                }`
            )
            .join("\n\n")}`;
    return new Response(content, {
        headers: { "Content-Type": "text/plain; charset=utf-8" },
    });
};
Enter fullscreen mode Exit fullscreen mode

and then just build your application using the usual commands.
Read the full article here Generating llms.txt file for your astro site

Comments 0 total

    Add comment