Miscellaneous

Adding meta description in jekyll posts

 

Add this in your default html file in _layouts.


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

 

What the above code does is, it checks for the description in your post, if it is present it picks it. Otherwise it adds the default one.

 

Then add description in your markdown files in _posts. Something like this


---
layout: post
title: "The title of your page"
description: The description, that is gonna be picked.
date: 2014-12-20 19:33:04
---

You’re done. 🙂

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s