October 29 2021
Jekyll Tip: Absolute URLs for Links and Images in RSS Feed
When I write a post and add an image, the image lives in the “files” folder. When Jekyll builds the static site locally, I can see the image inline. When I push the site to GitHub Pages, I can see the image online in the post with my web browser. But when I view the feed in an RSS reader (Reeder for me), no image.
The issue is the URL for the image is a relative path instead of an absolute path:
The RSS reader doesn’t know what the base path is. But if I wrote it with the absolute URL format locally, I couldn’t see it until I pushed the post live.
Web browsers handle relative URLs, but RSS readers are not consistent about it. You can add “xml:base” to your feed, but there is no guarantee that the RSS reader will observe it.
Below is a quick Jekyll hack to replace relative URLs for links and images with absolute URLs in
/feed.xml, using Liquid’s
Here is the code in the context of my entire
By replacing the relative links to absolute links in the RSS feed, the post is viewable in development and in production as well as in an RSS reader, without any modifications.