Extract the first image from a post in Jekyll ================================================================================ I decided that I want to show an image next to posts in my “article list” type pages in Jekyll. It would be tedious to go through each post and add a piece of Yaml frontmatter to indicate a “post image” (even though I had this at one point in the past (https://blog.omgmog.net/post/adding-more-post-metadata-to-jekyll-with-yaml/)!), so how could I automate this? [IMAGE: https://blog.omgmog.net/images/tooth-pull.png] All of my posts exist as Markdown in the codebase, but Jekyll parses this to HTML when generating the {{ post }} object. This chunk of HTML can in turn be parsed/split to find the first occurance of an image, and grab it: {% assign images = post.content | split:"