Skip to content

Comments

Integrate with Yoast SEO llms.txt to use .md URLs#4

Open
ilicfilip wants to merge 2 commits intomainfrom
filip/yoast-llms-txt-integration
Open

Integrate with Yoast SEO llms.txt to use .md URLs#4
ilicfilip wants to merge 2 commits intomainfrom
filip/yoast-llms-txt-integration

Conversation

@ilicfilip
Copy link
Contributor

Summary

  • When Yoast SEO's llms.txt feature is active, rewrites post/page URLs to .md versions
  • Wraps Yoast's generation triggers (option toggle, settings change, weekly cron) with wpseo_canonical, post_link, page_link, and post_type_link filters at priority 9/11 around Yoast's priority 10
  • Only loaded when Yoast SEO is active (WPSEO_VERSION check on plugins_loaded)
  • Respects the markdown_alternate_supported_post_types filter — only rewrites URLs for registered post types

Addresses the feature request in #1. The CPT .md URL bug reported in the comment is a separate fix in #3.

Test plan

  • Enable Yoast SEO's llms.txt feature
  • Verify /llms.txt contains .md URLs for posts and pages
  • Verify .md URLs in llms.txt resolve to markdown content (200)
  • Verify non-post URLs (categories, sitemap) are unchanged
  • Verify products and other unsupported post types are unchanged
  • Disable Yoast SEO and verify plugin still works without errors

🤖 Generated with Claude Code

When Yoast SEO's llms.txt feature is enabled, post/page URLs in the
generated file now point to .md versions instead of HTML URLs. This
follows the llms.txt spec recommendation to link to clean markdown.

The integration wraps Yoast's generation triggers (option changes, cron)
with permalink filters at priority 9/11 around Yoast's priority 10, so
URLs are rewritten inline during generation with zero file I/O overhead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jdevalk
Copy link
Member

jdevalk commented Feb 17, 2026

Consolidation note: keep this integration PR isolated while URL/rewrite fixes/refactors settle (#8/#9 and RewriteHandler refactors).

@ilicfilip
Copy link
Contributor Author

I have tested this PR and as far I can see it is working, at least from our end.

While testing this PR, I found that after changing the permalink structure (e.g. to /%postname%/), the URLs in llms.txt become empty, example post:
- [Advanced PHP Techniques](): Advanced PHP tips for modern development

This is a Yoast SEO issue, not caused by our plugin.

Root cause

When the permalink structure changes, Yoast's Indexable_Permalink_Watcher intentionally sets all stored permalinks to NULL in the wp_yoast_indexable table (source) and queues a background re-indexing job.

However, Yoast does not re-trigger llms.txt generation after this happens. The llms.txt file is only regenerated on:

  • Weekly cron (wpseo_llms_txt_population)
  • Toggling the llms.txt feature in Yoast settings
  • Changing llms.txt page selection settings

So if llms.txt is regenerated (e.g. by toggling the feature) before the background re-indexing completes, the indexables still have NULL permalinks, and Canonical_Presenter::get() returns empty strings.

How to reproduce

  1. Enable llms.txt in Yoast SEO — URLs are correct
  2. Change the permalink structure (Settings → Permalinks)
  3. Disable and re-enable llms.txt in Yoast settings
  4. Check llms.txt — URLs are empty

@ilicfilip ilicfilip marked this pull request as ready for review February 19, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants