samuelreichor / craft-llmify
Optimize your site for LLMs
Package info
github.com/samuelreichor/craft-llmify
Type:craft-plugin
pkg:composer/samuelreichor/craft-llmify
Requires
- php: >=8.2
- amphp/http-client: ^5.3
- craftcms/cms: ^5.0.0
- league/html-to-markdown: ^5.1
- paquettg/php-html-parser: ^2.2
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
Suggests
- samuelreichor/craft-insights: Adds an LLM-bot analytics dashboard.
Provides
None
Conflicts
None
Replaces
None
README
Supercharge Your Craft CMS Content for AI
LLMify makes your Craft CMS content instantly AI-ready. It transforms your templates into clean, structured outputs, giving you full control over what's included.
Why LLMify?
AI models like ChatGPT struggle to read websites built for people. They see a wall of code, menus, ads and sidebars, and that noise hides the content that matters. LLMify turns your Twig templates into clean, structured Markdown and serves it to AI crawlers, agents and anyone asking for it.
Markdown is rendered on demand and cached with Craft's element cache tags, so it is always up to date and blazingly fast.⚡️
Features
Content
- Template-Level Control: Mark what belongs in the Markdown with the
{% llmify %}and{% excludeLlmify %}Twig tags. - CSS Class Exclusion: Define classes to leave whole parts of the page out of the Markdown.
- YAML Front Matter: Configurable metadata with inheritance from site to section to entry.
- Twig Functions:
mdUrl(),chatGptUrl()andclaudeUrl()return an element's Markdown URL and links that open it in ChatGPT or Claude.
AI Content Delivery
- Markdown URLs: Every page is available as Markdown at its URL with
.mdappended, the homepage at/index.md. - Content Negotiation: Requests with an
Accept: text/markdownheader get the Markdown of the page. - AI Crawler Detection: Known AI crawlers (GPTBot, ClaudeBot, ChatGPT-User and more) get the Markdown automatically. You can add your own user agents.
- llms.txt: Generates
llms.txtand/.well-known/llms.txtas an index of your content. - Discovery Tags: Injects
<link rel="alternate" type="text/markdown">and<link rel="describedby" href="/llms.txt">into your HTML head, as recommended by the llms.txt spec. - Response Headers: Markdown responses send
Vary,X-Robots-Tag: noindex, nofollowand aLinkheader withrel="canonical"andrel="describedby". - WebMCP: Optionally exposes your content to in-browser AI agents through the experimental WebMCP standard.
Caching
- Always Up to Date: The cache uses Craft's element cache tags, so related entries, assets and globals invalidate it too.
- Cache Duration: The
cacheDurationsetting limits how long a page stays cached. - Cache Warming:
php craft llmify/markdown/generatecaches every page that is not cached yet, e.g. nightly on sites under heavy load. The utility can do the same in a queue job. - Clearing: Clear the cache in the LLMify utility, under Utilities > Clear Caches or with
php craft clear-caches/llmify. - Failure Reporting: Pages whose Markdown could not be rendered are listed on the dashboard, and the element sidebar shows the reason.
Content Management
- Hierarchical Settings: Site, section and entry level configuration with inheritance.
- Per-Entry Control: Include or exclude individual entries with the LLMify Settings field.
- Element Sidebar: Shows whether a page is cached, since when and its size in tokens.
- Dashboard: Site setup scores, section statistics and cache status at a glance.
- Permissions: Granular user permissions for every part of the plugin.
- Preview Targets: Preview the Markdown right from the entry editor.
Integrations
- SEOmatic: Populate front matter from SEOmatic fields.
- Craft Commerce: Commerce products are supported alongside entries.
- Blitz: Requests for Markdown bypass the Blitz cache. This needs Blitz to serve its cache through PHP; when the web server serves the cached files directly, content negotiation and crawler detection can not reach Craft.
Headless
- Headless Mode: For sites where Craft does not render the front end (e.g. a separate Nuxt, Next or Astro app). LLMify fetches your front end URLs (the site's base URL), converts the HTML to Markdown and caches it for
cacheDuration. Use the exclude classes to leave parts of the page out. - Content API: Pull the Markdown cross-domain so your front end can serve it under its own domain:
GET /actions/llmify/api/llms-txt?site=<handle|id>GET /actions/llmify/api/page?uri=<uri>&site=<handle|id>returns the Markdown of a single page, including front matter.
- On-Demand Convert:
POST /actions/llmify/api/convertwith{ "url": "<front-end URL>" }converts a single page live. The URL must belong to one of your sites' base URL hosts. - API Token: Protect the API with a token sent in the
X-Llmify-Tokenheader.
Requirements
This plugin requires Craft CMS 5.0.0 or later and PHP 8.2 or later.
Documentation
Visit the LLMify documentation for all documentation, guides, and developer resources.
Support
If you encounter bugs or have feature requests, please submit an issue. Your feedback helps improve the plugin!