GitHub Pagesのカスタムドメイン設定,HugoのTaxonomiesでのブログポストのカテゴリ分け

GitHub Pagesのカスタムドメイン設定

Pages側

Settings -> Pages でCustom domainに使いたいドメインを入力

Enforce HTTPS にチェックしておく(DNS設定してから)

ドメインのDNS設定

Porkbunで管理しているドメインなら,DNS設定でGitHub用の設定が1クリックでできる.GitHub Pages側のデフォルトドメインだけ自分で入力すればOK

Hugoの設定

hugo.tomlのbase_urlを自分のドメインにする

GitHub Actionsの設定

Github Actions用のデプロイファイル

hugo \
  --gc \
  --minify \
  --baseURL "${{ steps.pages.outputs.base_url }}/"

--baseURLの行を削除しておく.これが残っているとCSSがうまく当てられなくてページが崩れてしまう

Hugoのポストのカテゴリ分け

hugo.tomlで以下を追記

[taxonomies]
  category = "categories"
  tag      = "tags"

カテゴリは大きな括り,タグは細かいラベルづけに使う

個別のカテゴリやタグは個別のポストのfront matterに記述すれば良い.例えば,以下のような感じ

+++
date = '2026-01-11T09:53:31+09:00'
draft = false
title = 'Custom_domain_and_taxonomies_hugo_githubpages'
categories = ["musings"]
tags = ["hugo", "github pages", "100 days output"]
+++

もしyaml形式なら以下の書き方

title: "Custom_domain_and_taxonomies_hugo_githubpages"
date: 2026-01-11T09:53:31+09:00
draft: false
categories:
  - musings
tags:
  - hugo
  - github pages
  - 100 days output

これで,/categories/日記/ などカテゴリページ,/tags/hugo/ などタグページが自動生成される