How to prevent an include in feed.xml?

Apparently when rendering feed.xml you don’t have access to the page variable? I’m trying to include an image unless I’m in feed.xml, but {% unless page.url == "/feed.xml" %} doesn’t seem to be a valid way to accomplish it. I tried just outputting {{ page.url }} and it looks like it just doesn’t even exist in the context of rendering feed.xml. [edit: see below for a correction to this one sentence.] Am I missing something? Is there some other way to test whether the system is rendering feed.xml? Thanks in advance for your assistance! :sunglasses:

Oh shoot, turns out I hadn’t troubleshooted this nearly as well as I’d thought. It is outputting the page URL, but it’s the URL of each individual post. So that’s not going to work. Original question still stands: how can I figure out I’m in the context of rendering feed.xml so I can conditionally exclude some content?

I’m not sure what it is you are doing, can you paste the code of feed.xml?

if you are using a for loop is the iterator called page? like for page in site.posts? if so maybe you need to name it something else? or grab the page.url above that and assign it to something else and then use that in your comparison? you could also use a custom variable like exclude in the feed.xml front matter and then assign that.

I actually can’t find the code for my feed.xml. Is there actually a layout or page file for that? If so I’m not sure where to find it (I’m using GitHub Pages). I assumed (apparently naively) there wasn’t one and Jekyll was just doing whatever it does.

are you using a plugin for that? is there a link to your repo? I think there is a plugin called jekyll-feed? if you are using that you might want to check and see if there is a docs page for it where they might tell you if you can configure it as you like.

1 Like

If you’re using GitHub-pages to build/host then you’re also using the jekyll-feed plugin. The layout it uses to generate an Atom feed is here:

Let me provide more context. I have an include called endmark.html. It contains a single image that marks the end of an article. I include at or near the end of every post on my blog.

{% include endmark.html %}

I noticed when I consume my blog in my feed reader that the image looks terrible. The proper CSS isn’t being applied and the image is much too large. Since the endmark is more of a stylistic element and all other styles are removed when viewing in a feed reader, I want to simply remove the endmark from the version of my site served up in feed.xml.

So my plan (and maybe I’m approaching this all wrong) was to change the content of the endmark.html include so that if it was being included in feed.xml ot would simply produce no output. Something like this:

{% unless page.url == '/feed.xml' %}<img src="" />{% endunless %}

Since that doesn’t work, how can I accomplish this instead. I don’t see any unique variables in the feed.xml layout that I could key off of to detect that my include is being rendered in that context. What am I missing?