そのセクション内にある全記事へのリンクを書き出したページをつくる。
成果物
前提
ここまでできたら基礎はOK。今回はteraの構文について少し詳しく学ぶ。
流れ
{section}/section.htmlを追加する{section}/_index.mdを追加する
とりあえず今回はblogセクションをつくる。そしてそのセクションにある全記事のリンクを一覧する。
1. {section}/section.htmlを追加する
いきなり山場にして核心。
- 端末で
$SITE_ROOTへ移動する templates/に移動するmkdir blogするtouch section.htmlする
templates/blog/section.html
<html> <body> <h1>{{ section.title }}</h1> <ul> {% for page in section.pages %} <li><a href="{{ page.permalink }}">{{ page.title }}</a></li> {% endfor %} </ul> </body> </html>
2. {section}/_index.mdを追加する
content/blog/_index.html
+++ title = "ブログ" sort_by = "date" template = "blog/section.html" page_template = "blog/page.html" +++
templates/blog/page.htmlは空でいいので作っておく。
3. zola buildする
- 端末で
$SITE_ROOTへ移動する zola buildするpublic/にblog/index.htmlができる
<html> <body> <h1>ブログ</h1> <ul> </ul> </body> </html>
まだページがひとつもないからリンクも作られない。
所感
つぎはセクション配下のページをつくる。
対象環境
- Raspbierry pi 4 Model B
- Raspberry Pi OS buster 10.0 2020-08-20 ※
- bash 5.0.3(1)-release
- zola 0.14.0
$ uname -a Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux