もう公開しないんだけどgithubリポジトリの中には残しておくか……という、Hugoで生成されないページセクションを作った。
公式ドキュメントでは、本文だけが一度だけ必要といったユースケースが紹介されています。
Frontmatterの_build
オプションとcascade
を利用してセクション全体を生成されないようにします。
あとhugoのビルドコマンドには--cleanDestinationDir
を追加して、publicディレクトリから存在しないディレクトリを削除するようにする。
cleanDestinationDirDefault value: false
When building, removes files from destination not found in static directories.
https://gohugo.io/getting-started/configuration/#cleandestinationdir
config.toml(hugo.toml)などで設定もできるっぽい。
手順
-
例えば、
/content/blog/archived
というディレクトリのなかに非公開にしたい記事を全部ぶち込む -
_index.md
を作成 - frontmatterを記述
-
ビルドコマンドに
-cleanDestinationDir
を追加
/content/blog/archived/_index.md
---
_build:
list: false
render: false
cascade:
_build:
list: false
render: false
title: Archived Posts
---
以上です。