How MemberSpace Can Protect Jekyll Blog Posts
Disclosure: Some of the links below are affiliate links.
Today, by accident, I discovered that it is possible to use MemberSpace to protect some blog posts so they are available only to members.
There are two steps:
- Step 1: Protect a URL in mass using the MemberSpace backend, e.g.
/tax/*
. - Step 2: Use
tax
as a category for the post.
The blog post’s title will appear on the homepage. When a reader clicks on the link, the reader is redirected to the log-in page for members.
Complication: RSS Feed
Problem: RSS Feed Content Not Protected
I realized and confirmed that the RSS feed for hanisarji.com provided the entire post’s content, even if I followed the steps above.
In an email on Nov. 11, 2021, MemberSpace’s support confirmed that it does not protect content on RSS feeds: “[T]he RSS feed removes your domain from the equation so we can’t protect content on those feeds unfortunately.”
Workaround: Use Post Excerpts
As a workaround, I changed my RSS feed to show only post excerpts, instead of the entire post.1
In feed.xml
, I changed post.content
to post.excerpt
:
After making this change, I realized that I must become more intentional with my post excerpts:
- By default, Jekyll uses the first paragraph of a post as an excerpt.
- You can indicate a post excerpt separator in the post’s YAML. But if you write
excerpt_separator: <!--more-->
and don’t have<!--more-->
in your post, the RSS feed will display the entire post. - You cannot start a post with an HTML comment (
<!-- Comment -->
) as doing so would make the comment appear in the RSS feed.2 - You cannot start a post with a
raw
Liquid tag without making a post excerpt because the RSS feed would show no post content.
Additional Thoughts
(1) If I protect posts this way, I need to indicate that a post is for members and requires signing in. I think the easiest way to do this is to add [Members]
to the end of the title.
(2) If I want a post stream that is just for members, I will use Jekyll’s collections.
-
Despite the annoying ads on the page, the code for the workaround is explained on How can I get a post excerpt in Jekyll?, NEWBEDEV. ↩
-
I tried to remove comments from appearing in the post’s excerpts with the following change to
feed.xml
, but it didn’t do anything:<description>{{ post.excerpt | xml_escape | replace_regex: '/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g', '' }}</description>
↩