逐步教學

3. Front Matter

Front matter 是 YAML 程式碼片段,置於檔案開頭的兩個三破折號行之間。

你可以使用 Front matter 為頁面設定變數

---
my_number: 5
---

你可以使用 page 變數,在 Liquid 中呼叫 Front matter 變數。例如,要輸出上面 my_number 變數的值

{{ page.my_number }}

使用 Front matter

變更網站上的 <title>,以使用 Front matter

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

Jekyll 必須處理頁面上的任何 Liquid 標籤,你必須在頁面上包含 Front matter。

若要在不定義 Front matter 中的變數的情況下,讓 Jekyll 處理頁面,請使用

---
---

接著,你將進一步瞭解版面配置,以及為什麼你的頁面會使用比純 HTML 更多的原始碼。

  1. 設定
  2. Liquid
  3. Front Matter
  4. 版面配置
  5. 包含
  6. 資料檔案
  7. 資產
  8. 部落格
  9. 彙整
  10. 部署