Pages

03 November, 2026

Sitecore.MarkdownForAI: An Ask AI Button for Sitecore MVC Pages

More and more readers do not read an article to the end anymore. They copy it into ChatGPT or Claude and ask their own questions. I wanted to make that easy on Sitecore sites, so I built a small open-source module: Sitecore.MarkdownForAI. It adds an Ask AI button to your pages, and gives the AI assistant a clean copy of the page to read.

It works on Sitecore 10.1 to 10.5 with MVC renderings.

The Problem: AI Reads Your Footer Too

When an AI assistant opens an article page, it gets the full HTML: the mega menu, the search box, the cookie banner, the footer with forty links and kilobytes of script. The article is in there somewhere. The assistant has to dig it out, spends its context on the noise, and sometimes answers from the footer instead of the article.

What the Module Does

Two things:

  • An Ask AI button. Readers pick ChatGPT, Claude or Perplexity from a dropdown, and the assistant opens with the page already in the prompt.
  • A Markdown version of every page. Add .md to any URL and you get the same page as Markdown, without the header, menus or footer. This is the URL the button hands to the assistant.
https://www.example.com/articles/dental-care-for-dogs       the page, with the Ask AI button
https://www.example.com/articles/dental-care-for-dogs.md    the same page as Markdown

Here is a sample article page on Sitecore MVC, with a header, menu and search box, and the Ask AI button under the summary:

Sample article page on Sitecore MVC with the Ask AI button under the summary

The Ask AI Button

Ask AI dropdown with Open in ChatGPT, Open in Claude, Open in Copilot, Copy page as Markdown and View as Markdown

The module ships with ChatGPT, Claude and Perplexity. On my test site I added Copilot and turned Perplexity off, just by editing items, which is what you see above. The dropdown has one entry per assistant, plus two more:

  • Open in ChatGPT / Claude / Perplexity: opens the assistant in a new tab with a prompt like "Read this page so I can ask you questions about it: https://www.example.com/articles/dental-care-for-dogs.md".
  • Copy page as Markdown: copies the clean page to the clipboard, for any other AI tool.
  • View as Markdown: opens the .md version in a new tab.

Nothing about the button is hard-coded. New assistants show up every few months, and the prefill links they accept (such as https://chatgpt.com/?q=) are not documented public APIs, so they can change. Everything is a Sitecore item under /sitecore/system/Modules/Markdown For AI/Ask AI:

ItemFieldValues
Ask AI (settings)Button LabelButton text, for example "Ask AI about this page"
PromptText sent to the assistant. {url} = Markdown URL, {page} = page URL, {title} = page title
Show Copy MarkdownChecked: show Copy page as Markdown
Show View MarkdownChecked: show View as Markdown
Max Link LengthLongest assistant link before the page is copied to the clipboard instead (default 6000)
ChatGPT, Claude, Perplexity or any assistant you addAssistant NameFor example ChatGPT
Link PatternAn https link where {prompt} is replaced with the prompt, for example https://claude.ai/new?q={prompt}. Without {prompt}, the page is copied to the clipboard and the assistant opens, ready to paste
Menu LabelMenu text (empty: "Open in" and the name)
HintSecond line of the menu entry
PromptA prompt for this assistant only (empty: the Ask AI prompt)
IconA small image from the Media Library
EnabledUnchecked: hidden from the dropdown

To add an assistant, an editor inserts one item and publishes. No code, no deploy. The dropdown follows the content tree order. For a different set per site, create another Ask AI settings item and pick it as the rendering's data source. Upgrades never overwrite these items.

The button is a rendering called Ask AI. You can add it in three ways:

  • Once for every article: add it to the article template's Standard Values.
  • Per page: put an ask-ai placeholder near the article title, and editors can add the button in the Experience Editor.
  • In code: call @Html.AskAi() in a view.

The Markdown Version

For the sample article page shown earlier, this is what /articles/dental-care-for-dogs.md returns:

---
title: "Dental Care for Dogs: A Simple Home Routine"
description: "Why dental disease is so common in dogs, the signs to look for, and a five-minute daily routine."
url: "https://www.example.com/articles/dental-care-for-dogs"
language: "en"
last_updated: "2026-10-29"
---

# Dental Care for Dogs: A Simple Home Routine

## Why it matters

Most dogs show some sign of dental disease by the age of three. ...

## What else helps

| Option | How it helps | Notes |
| --- | --- | --- |
| Dental chews | Scrape plaque mechanically | Pick a size that cannot be swallowed whole |

No header, no menu, no newsletter, no footer. Headings, lists, tables and links stay. Every Markdown response also sends Link: rel="canonical" pointing to the HTML page and X-Robots-Tag: noindex, so search engines keep indexing the HTML page and not the copy.

How it decides what goes in:

  • The layout is never rendered, only its placeholders. Anything the layout file writes directly (a header partial, scripts) is gone automatically.
  • Excluded placeholders: renderings in the placeholders you list (by default header|footer|navigation|nav|breadcrumb) are skipped at any depth, before their controller or view runs. Dynamic placeholders such as footer-{GUID}-0 match too.
  • data-md-ignore on any element removes it, for example a share bar inside the article body.

The .md suffix is removed before Sitecore resolves the item, so wildcard items, custom item resolvers and language prefixes resolve the same item as for the HTML page. Only Request.RawUrl still shows the .md URL, so a custom resolver should read Request.Path instead.

Caching

Rendering a page and converting it costs CPU, so the finished Markdown is cached in memory and served early in httpRequestBegin, before Sitecore resolves the layout. On my test instance, the first request for an article took about 130 ms and the cached ones about 15 ms.

  • Cleared on publish, on every server.
  • Only successful pages are cached. Not-found and error pages are never stored.
  • Never cached: logged-in visitors, and content from the master database (local development and preview).
  • Your HTML rendering cache is not touched. A Markdown request does not read or write Sitecore's rendering cache.

How to Install

  1. Install Sitecore.MarkdownForAI-<version>.zip with the Installation Wizard. If you deploy through CI, there is also a NuGet package and the Sitecore CLI serialization.
  2. Rename App_Config/Include/MarkdownForAI/z.MarkdownForAI.Site.config.example to z.MarkdownForAI.Site.config and set your site name. Your settings live only in this file, so upgrades never touch them.
  3. Publish the Markdown For AI items.
  4. Add the Ask AI rendering to your page.

The .md pages are served on ContentDelivery and Standalone servers. All items live under Modules folders, so a Helix solution that serializes its own Foundation, Feature and Project folders never deletes them.

Settings

Most sites only change Sites and ExcludedPlaceholders. Every setting goes in z.MarkdownForAI.Site.config with the MarkdownForAI. prefix:

<setting name="MarkdownForAI.Sites" set:value="mysite" />
SettingDefaultPossible values
Enabledtruefalse turns off the .md pages
SiteswebsiteSite names, pipe separated, or * for every site except Sitecore's own. On other sites the button sends the normal page URL
Extension.mdThe suffix that asks for Markdown
ExcludedPathPrefixes/sitecore/|/-/|/api/|...Paths never treated as Markdown requests
ExcludedPlaceholdersheader|footer|navigation|nav|breadcrumbPlaceholder keys left out, at any depth
PlaceholdersemptyTop-level placeholders to render, in this order. Empty: all on the page
SkipTagsscript|style|form|nav|...HTML elements always removed
IgnoreClassesemptyCSS classes whose elements are removed
IncludeImagestruefalse drops images
TitleFieldsTitle|Page Title|HeadingFields for the title; the first non-empty one wins, then the display name
DescriptionFieldsMeta Description|...|AbstractFields for the description; the first non-empty one wins
FrontMatterFieldstitle|description|url|language|last_updatedFront matter lines to write, or none
CacheMinutes30Minutes to keep a page in memory. 0 turns the cache off
CacheSizeMB100Memory limit of the cache
CacheVaryByQueryStringfalsetrue only if components change their output based on the query string
NoCacheDatabasesmasterDatabases whose content is never cached
NoIndexHeadertruefalse stops sending X-Robots-Tag: noindex
Schemeemptyhttps to force it in generated URLs, for example behind an SSL offloader
AskAi.ScriptUrl/scripts/markdownforai/ask-ai.jsWhere the button's script is served from. Empty: load it yourself

What Is Not in This Version

I kept the first release small on purpose. These are not included:

  • WebForms pages: only MVC layouts get a .md version. On other layouts the button still works with the normal page URL.
  • llms.txt, field mappings, per-component rules and discovery headers. They are written up in the repository's docs/extending.md, so they can come back when there is a need.
  • Local and intranet sites: the assistant must be able to reach the .md URL. On a local host, use Copy page as Markdown and paste it.

Wrapping Up

  • Readers ask ChatGPT, Claude or Perplexity about your article with one click.
  • The assistant reads a clean Markdown copy of the page, not your menus and footer.
  • The assistants and the prompt are Sitecore items, so adding the next one is an editor task, not a deploy.
  • Install the package, set your site name, publish, and add the rendering.

If you are working on something similar, I would love to hear how you approached it. If you find the module useful, a star on GitHub helps with visibility.

Links

No comments:

Post a Comment

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }