もう公開しないんだけどgithubリポジトリの中には残しておくか……という、Hugoで生成されないページセクションを作った。 公式ドキュメントでは、本文だけが一度だけ必要といったユースケースが紹介されています。

Frontmatterの_buildオプションとcascadeを利用してセクション全体を生成されないようにします。

あとhugoのビルドコマンドには--cleanDestinationDirを追加して、publicディレクトリから存在しないディレクトリを削除するようにする。

cleanDestinationDir
Default value: false
When building, removes files from destination not found in static directories.
https://gohugo.io/getting-started/configuration/#cleandestinationdir

config.toml(hugo.toml)などで設定もできるっぽい。

手順

  1. 例えば、/content/blog/archived というディレクトリのなかに非公開にしたい記事を全部ぶち込む。
  2. _index.mdを作成
  3. frontmatterを記述
  4. ビルドコマンドに--cleanDestinationDirを追加

/content/blog/archived/_index.md

---
_build:
  list: false
  render: false
cascade:
  _build:
    list: false
    render: false
title: Archived Posts
---

以上です。