SR
Usage

Twig Functions

Link visitors to the Markdown version of a page or open it directly in ChatGPT or Claude.


LLMify registers three Twig functions for your front-end templates. Use them to build "View as Markdown" links or "Open in AI" buttons that hand the current page to ChatGPT or Claude.

All three functions accept an optional element. Without an argument they use the element of the currently rendered page. They return null when no Markdown is available for the element (no URI, excluded from LLMify, or its section is disabled), so always wrap the output in a null check.

mdUrl()

Returns the Markdown URL of an element, e.g. https://example.com/raw/news/my-article.md.

{% set url = mdUrl() %}
{% if url %}
    <a href="{{ url }}">View as Markdown</a>
{% endif %}

Pass an element explicitly to link to other pages, for example in an overview list:

{% for item in entries %}
    {% set itemUrl = mdUrl(item) %}
    {% if itemUrl %}
        <a href="{{ itemUrl }}">{{ item.title }} as Markdown</a>
    {% endif %}
{% endfor %}

chatGptUrl()

Returns a link that opens ChatGPT with a prompt asking it to read the page's Markdown, so the visitor can chat about your content right away.

{% set url = chatGptUrl() %}
{% if url %}
    <a href="{{ url }}" target="_blank" rel="noopener">Ask ChatGPT about this page</a>
{% endif %}

claudeUrl()

Same as chatGptUrl(), but opens the prompt in Claude.

{% set url = claudeUrl() %}
{% if url %}
    <a href="{{ url }}" target="_blank" rel="noopener">Ask Claude about this page</a>
{% endif %}
Note

The AI chat links point ChatGPT and Claude at the page's public Markdown URL. They only work on production domains the AI services can reach, not on local development URLs.


Copyright © 2026 Samuel Reichör