Grabbing the latest blog post from Jekyll using PHP
On my website, greggant.com I have a small section of my homepage where it always displays the title of my most current blog post. Prior to using Jekyll back when my blog was hosted on Tumblr, I used the API to grab the latest post via a URL. On Jekyll, the solution is even easier: Create a dummy template that only includes the page title and use PHP to write the blog post title.
Step 1: Create a blank template in _layouts
I created a template I named blank.html, the entire contents are one line:
Step 2: Create a url
Since the script I'll be using is all for public access, I kept it simple and decided to make a new page in the root of my blog. I named it currentpost.html.
It'd be possible to create a URL directly to the page, but for this solution, I opted in for absolutely the most minimum amount of work seeing I'd rather link from my portfolio to my blog's homepage instead of the the actual post..