1
votes

Some posts of my Jekyll RSS feed are link posts (after a click on the title they'll forward the reader to the external source URL). I setup an {% if post.link %} liquid filter for them in the feed.xml.

What I want is to display a "∞ Permalink" at the bottom of the link-posts in the RSS feed.

My question: Is there a way to display a Permalink at the bottom of every link post in the feed.xml file?

As a workaround I could set up an extra Permalink at the bottom of the post content area, but then it would also be displayed in the post itself, so I'd love to know if there's a more straight forward approach.

Update: I tried setting a separate Permalink lik this:

<a title="Permalink" class="permalink" href="{{ site.domain }}{{ page.url }}">∞ Permalink</a>

If I put the link in the bottom of an actual 2012-10-18-example-post.md file it works, but when I put it in a template it fails to show up in the RSS Feed Reader, c.f.:

...

  {{ content }}

 <a title="Permalink" class="permalink" href="{{ site.domain }}{{ post.url }}">∞ Permalink</a>

Anyone idea how to append the link to the content tag?

Here's my feed.xml - if that helps:

---
layout: none
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ site.name }}</title>
    <description>{{ site.description }}</description>
    <link>{{ site.url }}</link>
    <atom:link href="{{ site.url }}/feed.links.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts limit:30 %}
      {% if post.link %}
      <item>
        <title>Link:{{ post.title }}</title>
        <description>{{ post.content | xml_escape }}</description>
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
        <link>{{ post.link | escape }}</link>
        <guid isPermaLink="true">{{ post.link }}</guid>
      </item>

      {% else %}

      {% unless post.link %}
      <item>
        <title>{{ post.title }}</title>
        <description>{{ post.content | xml_escape }}</description>
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
        <link>{{ site.url }}{{ post.url }}</link>
        <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
      </item>
      {% endunless %}

      {% endif %}

    {% endfor %}
  </channel>
</rss>
1
This is sually considered bad form. Most (every?) reader will add a link to your content anyway from the <link> element. The content itself should just be the content and not include meta data.Julien Genestoux

1 Answers

0
votes

Add it to the appropriate <description> tag in your rss file. Don't forget that this is an XML document that contains HTML, so you must XML-escape your HTML content:

<description>
    {{ post.content | xml_escape }}
    &lt;a title=&quot;Permalink&quot; class=&quot;permalink&quot; href=&quot;{{ site.domain | xml_escape }}{{ post.url | xml_escape }}&quot;&gt;
        ∞ Permalink
    &lt;/a&gt;
</description>