Displaying Medium Posts on Your Jekyll Website

James Hamann
May 9, 2017 · 4 min read
require 'feedjira'module Jekyll
class MediumPostDisplay < Generator
safe true
priority :high
def generate(site)
jekyll_coll = Jekyll::Collection.new(site, 'external_feed')
site.collections['external_feed'] = jekyll_coll
Feedjira::Feed.fetch_and_parse("https://medium.com/feed/@YOUR_MEDIUMUSERNAME").entries.each do |e|
p "Title: #{e.title}, published on Medium #{e.url} #{e}"
title = e[:title]
content = e[:content]
guid = e[:url]
path = "./_external_feed/" + title + ".md"
path = site.in_source_dir(path)
doc = Jekyll::Document.new(path, { :site => site, :collection => jekyll_coll })
doc.data['title'] = title;
doc.data['feed_content'] = content;
jekyll_coll.docs << doc
$ touch medium_post_display.rb
RSS Feed for my Medium Profile
- external_feed
layout: default
<section id="main" class="wrapper style1">
<header class="major">
{% for e in site.external_feed %}
<h2>{{ e.title }}</h2>
<p>{{ e.feed_content }}</p>
{% endfor %}
<section class="special">
<ul class="actions">
<li><a href="{{ site.baseurl }}{{ e.url }}" class="button {% cycle '', 'alt'%}">Read More</a></li>

James Hamann

Written by

Software Developer https://jameshamann.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade