Explore More Passive Income Ideas

creating a custom 404 page in jekyll that converts

Rethinking the 404 Page in Static Sites When users hit a dead-end on your website, their experience doesn't have to end in frustration. A well-designed 404 page can guide lost visitors back on track, or even convert them into subscribers or customers. In Jekyll, crafting a custom 404 page offers both technical control and creative potential. Why Default 404 Pages Don’t Work The typical 404 page is bland, offers no direction, and causes users to bounce. Search engines also pick up on poor navigation. A custom solution not only improves SEO but also keeps your audience engaged. Creating a 404 Page in Jekyll To create a custom 404 page in Jekyll, all you need is a new file at your site root: 404.html Use your layout or a standalone HTML structure. Example: {% raw %} --- layout: default title: "Page Not Found" permalink: /404.html --- <div class="not-found"> <h2>Oops, this page doesn't exist</h2> <p>But don’t worry, her...

handling featured images in jekyll blogs

Why Featured Images Matter

Featured images are visual anchors for blog posts. They catch attention, improve click-through rates, and enhance the aesthetic of post listings. For Jekyll blogs, especially those deployed on GitHub Pages, adding featured image support can be done with just a few front matter fields and template updates—no plugins needed.

Step 1: Add a Featured Image Field to Front Matter

Open any post and define a new property, such as image, in the front matter. Example:

---
layout: post
title: "How to Improve Readability"
image: /assets/images/readability-cover.jpg
---

This path should point to an image you've uploaded to your assets directory (or wherever you keep static files).

Step 2: Display the Image in the Post Template

Edit your _layouts/post.html file (or whatever layout your blog uses) and insert the following Liquid code where you want the image to appear:

{% raw %}
{% if page.image %}
  <img src="{{ page.image }}" alt="{{ page.title | escape }}" class="featured-image">
{% endif %}
{% endraw %}

This ensures that only posts with an image defined will display one, maintaining layout consistency.

Step 3: Add Styling for Featured Images

To ensure a consistent look and responsive behavior, add styles in your CSS file:

.featured-image {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
  border-radius: 6px;
  object-fit: cover;
}

Step 4: Add Images to Homepage and Archives

If your homepage or tag/category listing uses an include like post-card.html, you can add a thumbnail version of the featured image. Example:

{% raw %}
<div class="post-card">
  {% if post.image %}
    <img src="{{ post.image }}" alt="{{ post.title }}" class="thumb">
  {% endif %}
  <h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
</div>
{% endraw %}

Thumbnail Style Suggestion

.thumb {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 10px;
}

Optional: Define a Default Image

If some posts are missing featured images, set a default fallback:

{% raw %}
{% if page.image %}
  <img src="{{ page.image }}" alt="{{ page.title }}">
{% else %}
  <img src="/assets/images/default.jpg" alt="Default featured image">
{% endif %}
{% endraw %}

Case Study: Personal Finance Blog Revamp

A solo finance blogger transitioned their Jekyll blog from text-heavy to visually engaging. By adding featured images to all recent posts and adjusting layouts, session durations increased by 25%. Readers were more likely to explore related articles thanks to visual consistency, and social sharing thumbnails improved drastically.

Managing Your Image Assets

  • Store all featured images in a dedicated folder like /assets/images/posts/
  • Use consistent naming like slug.jpg for each post
  • Compress images using tools like TinyPNG or Squoosh before uploading
  • Use alt attributes for accessibility and SEO

Performance Considerations

Don’t overload your homepage with large image files. Consider generating thumbnails or using a CSS class to constrain image size. For high-traffic sites, consider self-hosting on a CDN or using an image optimization service during your build process.

Featured Images in RSS and Meta Tags

To enhance social sharing, extend featured image support into your meta tags. For example, inside your _includes/head.html file:

{% raw %}
{% if page.image %}
  <meta property="og:image" content="{{ site.url }}{{ page.image }}">
{% endif %}
{% endraw %}

Conclusion

Featured images are a small change with big visual impact. They improve user experience, enhance social sharing, and contribute to better engagement metrics. With a few lines of Liquid and some front matter organization, your Jekyll blog can look significantly more polished and professional—without any plugin overhead.


Archives / All Content


© ShiftPathNet . All rights reserved.