astro-inference
v0.2.6
Published
Astro integration that auto-generates LLM-friendly text/plain pages and llms.txt for your site
Maintainers
Readme
astro-inference
Astro integration that automatically generates LLM-friendly pages for your site.
Adds two routes to any Astro project:
/llms.txt— structured plain-text index of your site, following the llms.txt standard/[page]/machine.txt— cleantext/plainmarkdown version of any page, optimized for LLM consumption
Installation
pnpm add astro-inference
# or
npm install astro-inference
# or
yarn add astro-inferenceSetup
// astro.config.mjs
import { defineConfig } from 'astro/config';
import astroInference from 'astro-inference';
export default defineConfig({
integrations: [
astroInference({
siteName: 'My Site',
siteDescription: 'What my site does in one sentence.',
}),
],
});That's it. No other configuration required.
Routes
/llms.txt
A machine-readable index of your entire site. Grouped by content collection, with titles and descriptions pulled from front matter.
# My Site
> What my site does in one sentence.
## Blog
- [Getting started](https://mysite.com/blog/getting-started) - A quick intro
- [Another post](https://mysite.com/blog/another-post)
## Machine-readable pages
Each page on this site has a plain-text version at `[page-url]/machine.txt`.
Example: `https://mysite.com/about/machine.txt`/[page]/machine.txt
A plain-text markdown version of any page. Scripts, styles, and footer are removed. Navigation links are preserved at the bottom so LLMs can traverse the site.
# My Site
> Source: https://mysite.com/about
> Machine-readable version - 2026-04-07
---
# About Us
We build great things for great people.
## Our values
- Honesty
- Speed
- Quality
## Navigation
- [Home](/)
- [About](/about)
- [Blog](/blog)
- [Contact](/contact)
---
Generated by astro-inference | https://mysite.com/llms.txtWorks for any route: /about/machine.txt, /blog/my-post/machine.txt, /docs/guide/machine.txt.
Content Filtering
The following are automatically removed from machine.txt output:
<script>,<style>,<head>— no code or styling<footer>,<aside>— peripheral content<header>— visual branding- Skip-to-content links (e.g.
#main-content,Skip to navigation) — accessibility anchors irrelevant to LLMs
Navigation links from <nav> elements are not removed — they are extracted and placed in a ## Navigation section at the bottom, so LLMs can follow links to other pages on the site. Duplicate links are deduplicated automatically.
Options
| Option | Type | Default | Description |
| ----------------- | ---------- | ------------- | ------------------------------------------------------- |
| siteName | string | hostname | Heading used in llms.txt |
| siteDescription | string | — | One-line tagline shown below the heading |
| exclude | string[] | [] | Paths to exclude. Supports /* wildcard suffix. |
| collections | string[] | auto-detected | Content collection names to include in llms.txt |
| llmsTxtPath | string | /llms.txt | Where llms.txt is served |
| machineSuffix | string | machine.txt | Suffix appended to each page route |
| attribution | boolean | true | Include footer in output. Set to false to remove it entirely. |
| customFooter | string | — | Replace the default footer text with your own string. |
Removing or customizing the footer
By default every output file ends with:
---
Generated by astro-inference | https://yoursite.com/llms.txtRemove it entirely:
astroInference({
attribution: false,
})Or replace it with your own text:
astroInference({
customFooter: 'Built with ❤️ by Acme Corp',
})Both options affect /llms.txt and every /[page]/machine.txt file.
Example with all options
astroInference({
siteName: 'Acme Corp',
siteDescription: 'We make the best widgets on the internet.',
exclude: ['/admin/*', '/private', '/thank-you'],
collections: ['blog', 'docs'],
llmsTxtPath: '/llms.txt',
machineSuffix: 'machine.txt',
attribution: true,
customFooter: 'Built with ❤️ by Acme Corp',
})Content Collections
If your project uses Astro Content Collections, astro-inference picks them up automatically.
Default collection names scanned: blog, posts, articles, pages, docs, work, projects, portfolio, news, events.
Use the collections option to specify exactly which collections to include — this avoids warnings for non-existent collections and gives you explicit control.
Front matter fields used:
| Field | Used in |
| -------------------------- | ----------------------------------- |
| title | Link label in llms.txt |
| description or summary | Description after — in llms.txt |
How It Works
- On
astro:config:setup,/llms.txtis injected viainjectRoute()andmachine.txtroutes are handled via Astro middleware. /llms.txtreads your content collections at request time and builds a grouped markdown index./[...slug]/machine.txtfetches the original page HTML, strips non-semantic elements, extracts navigation links, and converts the remainder to clean markdown.
No build-time scanning, no filesystem crawling — everything runs through Astro's existing request pipeline.
Requirements
- Astro 4.0 or later
- Node.js 18 or later
License
MIT
