fix(theme): serve /llms.txt without trailing-slash redirect#11
Merged
Conversation
WordPress's canonical redirect was 301-ing /llms.txt -> /llms.txt/, which AI crawlers don't expect (robots.txt-style files serve at the exact path). Disable redirect_canonical for the llms route, accept an optional trailing slash in the rewrite, and run the handler at priority 0 (before canonical). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Ensures the theme serves /llms.txt directly (robots.txt-style) without WordPress canonical redirecting it to a trailing-slash variant, improving compatibility with AI crawlers that expect an exact-path response.
Changes:
- Updates the rewrite rule to accept an optional trailing slash for the
llms.txtroute. - Disables
redirect_canonicalwhen serving thellms.txtvirtual endpoint to prevent/llms.txt→/llms.txt/redirects. - Runs the
llms.txtresponse handler earlier (template_redirectpriority0) so it executes before canonical redirect logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+479
to
483
| // Serve /llms.txt at the exact path (like robots.txt) — WordPress's canonical | ||
| // redirect would otherwise 301 it to /llms.txt/, which AI crawlers don't expect. | ||
| add_filter('redirect_canonical', function ($redirect_url) { | ||
| return ('1' === (string) get_query_var('minimalcode_llms')) ? false : $redirect_url; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #10.
/llms.txtwas 301-redirecting to/llms.txt/via WordPress's canonical redirect; AI crawlers expect a robots.txt-style file to serve at the exact path.redirect_canonicalfilter returnsfalsefor the llms route (no trailing-slash redirect)^llms\.txt/?$)template_redirectpriority 0 (before canonical)Verified locally:
php -lclean, static UI-marker test passes. Will confirm/llms.txt→ 200 (no redirect) after deploy.🤖 Generated with Claude Code