Scott Andrew

Blog

Posted May 12, 2025.

How to exclude content from 11ty RSS feeds

Every so often I'll want to post something here that I'm pretty sure will break feed readers. Some feed readers will scrub out things like JavaScript, style rules, and iframe elements in order to repackage them in an aesthetically-pleasing way or to remove content that might be considered dangerous. In any case there's a chance that my blog post might appear as a broken mess of images and text once a feed reader strips out any supporting markup.

My last post about easy image galleries is one such post, so I cooked up a way to specify content be hidden from feeds altogether. This 11ty filter will replace any element with the class feed-exclude with a link to the post instead.

So if a post contains something like this:

<p class="feed-exclude">Here is some content that might wreak havoc in a feed reader!</p>

...it'll be replaced with this in the RSS feed:

<p>(<a href="https://example.com/url/to/post">Visit the website to see this content.</a>)</p>

This filter also works on content enclosed in <feed-exclude> tags. I don't recommend that approach because it unnecessarily changes your document structure, but it can be useful if you want to exclude a large block of content.


No comments yet.
Be the first to comment!
Post a comment on "How to exclude content from 11ty RSS feeds | Scott Andrew"

Allowed HTML

<b>, <strong>, <u>, <i>, <em>, <s>, <big>, <small>, <sup>, <sub>, <pre>, <ul>, <ol>, <li>, <blockquote>, <code> escapes HTML, URLs automagically become links, and [img]URL here[/img] will display an external image.