Sarathlal N

Add meta description in Jekyll posts

The meta descriptions in web pages help us to get more visitors through Search Engine Result Pages. They can provide a brief introduction about our content as a search description. But we need unique meta descriptions for our web pages.

In Jekyll, we can use YAML front matter block of posts for this purpose. In our YAML front matter, set up a variable and assign value for that variable. We can access the value of this variable through our site using Liquid tags.

Then we will convert the value of this variable as a content of meta Description tag for our web pages. So remember that the value, the meta description must be a unique tiny description about our content.

If possible, try to use our keywords in meta description & limit meta description length in 160 characters.

Step 1: Add meta description in post / page YAML front matter like below example.

---
layout: post
title: Add meta description in Jekyll posts & get more visitors
description: We can easily add meta description in Jekyll post. It can generate more visitors for our blog through SERP(Search Engine Result Pages) & indirectly improve SEO.
---

Step 2: Access this variable from YAML front matter & use it for HTML meta description tag in HTML head section of template file.

{% if page.description %}<meta name="description" content="{{ page.description }}">{% endif %}

This line of code say that, if there is any description in YAML front matter, use it as a content for HTML meta description tag. If there is no any description at there, Jekyll never generate meta description tag for our web pages.

Got a project in mind? Send me a quick message, and I'll get back to you within 24 hours!.

Recent Posts

  1. Disabling Payment Methods in WooCommerce Based on Conditions
  2. How to Update Product Quantity in WooCommerce Using Custom Code
  3. Dynamically Generating a Table of Contents in WordPress
  4. Direct Checkout in WooCommerce - Add Product to Cart from Checkout Page & Skip Shop, Product, and Cart Pages
  5. Understanding the Impact of git reset --hard Command

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.