以下の内容はhttps://ytyaru.hatenablog.com/entry/2023/05/08/000000より取得しました。


zolaで一覧ページを作る({section}/_index.md)

 そのセクション内にある全記事へのリンクを書き出したページをつくる。

成果物

前提

 ここまでできたら基礎はOK。今回はteraの構文について少し詳しく学ぶ。

流れ

  1. {section}/section.htmlを追加する
  2. {section}/_index.mdを追加する

 とりあえず今回はblogセクションをつくる。そしてそのセクションにある全記事のリンクを一覧する。

1. {section}/section.htmlを追加する

 いきなり山場にして核心。

  1. 端末で$SITE_ROOTへ移動する
  2. templates/に移動する
  3. mkdir blogする
  4. 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する

  1. 端末で$SITE_ROOTへ移動する
  2. zola buildする
  3. public/blog/index.htmlができる
<html>
<body>
<h1>ブログ</h1>
<ul>
</ul>
</body>
</html>

 まだページがひとつもないからリンクも作られない。

所感

 つぎはセクション配下のページをつくる。

対象環境

$ uname -a
Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux



以上の内容はhttps://ytyaru.hatenablog.com/entry/2023/05/08/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14