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
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: "images/homepage.png"
meta:
title: "This title will be used only as the meta title"
description: "This description will be used only as the meta description"
Here is the actual logic we use for the meta tags.
<!-- layouts/partials/framework/head/seo-meta-tags.html -->
<title>{{ if .Params.meta.title }}{{ .Params.meta.title }}{{ else }}{{ .Title }}{{ end }}</title>
{{ if .Params.meta.description }}
<meta name="description" content="{{ .Params.meta.description | safeHTML }}"/>
{{ else if .Params.description }}
<meta name="description" content="{{ .Params.description | safeHTML }}"/>
{{ end }}
{{ if .Params.meta.keywords }}
<meta name="keywords" content="{{ .Params.meta.keywords }}">
{{ end }}