jekyll/docs/_docs/step-by-step/03-front-matter.md

1.1 KiB

layout title position
step Front Matter 3

Front matter is a snippet of YAML placed between two triple-dashed lines at the start of a file.

You can use front matter to set variables for the page:

---
my_number: 5
---

You can call front matter variables in Liquid using the page variable. For example, to output the value of the my_number variable above:

{% raw %}

{{ page.my_number }}

{% endraw %}

Use front matter

Change the <title> on your site to use front matter:

{% raw %}

---
title: Home
---
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{{ page.title }}</title>
  </head>
  <body>
    <h1>{{ "Hello World!" | downcase }}</h1>
  </body>
</html>

{% endraw %}

{: .note .info } You must include front matter on the page for Jekyll to process any Liquid tags on it.

To make Jekyll process a page without defining variables in the front matter, use:

---
---

Next, you'll learn more about layouts and why your pages use more source code than plain HTML.