Jekyll Read more link

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)

Brendan
05. Jun 2019, 23:24

Hey this is cool

Andrew
29. Dec 2019, 07:49

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.

Stanko
29. Dec 2019, 09:35

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!

Simone
28. Dec 2020, 18:02

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

Stanko
28. Dec 2020, 18:31

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