Meta tags are automatically generated for each page. But they can also be defined on a per page basis.
By default the pages title
and description
frontmatter are used to generate the pages <title>
You can override this by using the meta_title
, meta_description
and meta_image
properties in a page frontmatter.
# content/home.md
---
layout: home
permalink: "/"
title: "This title will be displayed on the homepage as a heading and used in the meta title if not overriden."
description: "This title will be displayed on the homepage as a paragraph and used as meta description if not overriden"
image: "/assets/images/homepage.png"
meta_title: "This title will be used only as the meta title"
meta_description: "This description will be used only as the meta description"
meta_image: "/assets/images/social-feature-image.png"
Here is the actual logic we use for the meta tags.
<!-- _includes/framework/global/head/seo-meta-tags.html -->
<title>{% if page.meta_title %}{{ page.meta_title }}{% elsif page.title %}{{ page.title }} - {{ site.title}}{% else %}{{ site.title }}{% endif %}</title>
{% if page.meta_description %}
<meta name="description" content="{{ page.meta_description }}"/>
{% elsif page.description %}
<meta name="description" content="{{ page.description }}"/>
{% endif %}
{% if page.meta_keywords %}
<meta name="keywords" content="{{ page.meta_keywords }}">
{% endif %}