2

I have a personal blog I set up using Jekyll and getting hosted on GitHub Pages.

How can I make sure people access any article from my blog fully only by visiting it, not through an RSS reader such as Feedly? My Google searches provided me with no useful practical information. I have not come across anything that I deemed useful when I went through either the _config.yml file among the Jekyll files for my blog or its general settings on github.com.

Ideally, I would like people to be notified of a new article from my blog through their RSS reader and be also provided with a glimpse of the new article but not to be able to read all of it without directly visiting the blog.

1 Answer 1

1

Jekyll provide a basic RSS feed syntax which should assist. To use an RSS file in Jekyll, create a file called feed.xml in your root directory and add the following:

---
layout: null
---

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

    <channel>
        <title>{{ site.title }}</title>
        <link>{{ site.url }}</link>
        <atom:link href="{{ page.url | prepend: site.url }}" rel="self" type="application/rss+xml" />
        <description>{{ site.description }}</description>
        <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
        {% for post in site.posts %}
        <item>
            <title>{{ post.title }}</title>
            <link>
                {{ post.url | prepend: site.url }}
            </link>
            <description>
                {{ post.content | escape | truncate: '400' }}
            </description>
            <pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
            <guid>
                {{ post.url | prepend: site.url }}
            </guid>
        </item>
        {% endfor %}
    </channel>
</rss>

The important line there is {{ post.content | escape | truncate: '400' }} which shortens the post content to I believe 400 characters (approx. 55 to 100 words).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.