Jump to content

Jekyll Read more link

Posted in Jekyll · 1 minute read

Please note that I'm not using Jekyll anymore, so this post might be outdated.

It is nice to use post.excerpt instead of post.content on your Jekyll home page, but then users can't see if there is more to read until they open the whole post.

To add Read more link, you can use this simple snippet.

{% if post.excerpt != post.content %}
    <a href="{{ site.baseurl }}{{ post.url }}">Read more</a>
{% endif %}

Comments (5)

28. December 2020
Stanko

Glad it helped and that people are still finding these old posts of mine :) Cheers!

28. December 2020
Simone

Great stuff, works like a charm — thanks for sharing!

29. December 2019
Stanko

Hey Andrew,

Not sure what you have done wrong. Are you missing Front Matter section in your post? This tells Jekyll which layout to use, and without it, it will render unstyled HTML.

Cheers!

29. December 2019
Andrew

Hi,

New to blogging with Jekyll, so glad I found the your site. Very professional.

The code, when added to my index.html, basically works. I have still done something wrong. I start with a test excerpt in the front matter, and get the intended hyperlink that takes me to the whole post.

But the markdown post doesn't get formatted properly. I have a couple of animated gif files at the top, which appear in the wrong size. The text is now the wrong size also, and scroll bars appear for the overall over-scaled post. It seems like the theme design for the basic theme (Lanyon), is stripped out and replaced by basic HTML . Any help appreciated.

Cheers,

Andrew.

5. June 2019
Brendan

Hey this is cool