Link Posts with Jekyll

less than 1 minute read

Now that I have Jekyll publishing automated, why not do link posts? For one, Jekyll does not support link posts out of the box. However, Tuan Anh figured out how to tweak Jekyll to support link posts: Posting Link Post in Jekyll by Tuan Anh Tran.

This is the code I used to modify my post.html file (in the _layouts directory):

{% if page.link %}  
<h2><a href="{{ page.link }}">{{ page.title }}</a></h2>  
{% else %}  
<h2> {{ page.title }} </h2>  
{% endif %}

NOTE: I had to use page.link where Tuan Anh used: page.post-link (in their code).

Unfortunately, clicking the title on the homepage still goes to a permalink on my site. It is not until one visits the actual, individual (link) post when the title is hyperlinked to the source. This is due to Jekyll not knowing the internals of any post when generating the homepage. Still, I thank Tuan Anh for the tip and will use it often!

Direct Link