HugoのテーマをBlowfishからStackに変更しました

ブログのHugoテーマをBlowfishからStackに変更しました。

環境

Hugo v0.151.0+extended
テーマ: Blowfish → Stack
OS: Windows 11

テーマ変更の手順

Blowfishテーマの削除

まず、既存のBlowfishテーマを手動で削除しました。

# themes/blowfishディレクトリを手動削除
themes/blowfish

# .gitmodulesからblowfishの設定を削除
# [submodule "themes/blowfish"]
#     path = themes/blowfish
#     url = https://github.com/nunocoracao/blowfish.git

Stackテーマのインストール

git submoduleを使用してStackテーマを追加しました。

git submodule add https://github.com/CaiJimmy/hugo-theme-stack/ themes/hugo-theme-stack

設定ファイルの移行(TOML → YAML)

Stackテーマでは設定ファイルでYAMLを使用しています。
今まで使用していたBlowfishのTOML形式の設定ファイルをすべて1つのYAMLファイルにまとめられそうだったので、以下のように変更しました。

変更前の構成:

config/_default/
├── hugo.toml
├── languages.toml
├── menus.toml
└── params.toml

変更後の構成:

config/_default/
└── hugo.yaml  # すべてを1つのファイルに統合

主な設定内容:

baseurl: https://kazusa-pg.com/
languageCode: ja-JP
theme: hugo-theme-stack
title: かずさプログラマーの雑記帳
copyright: かずさプログラマー

DefaultContentLanguage: ja
hasCJKLanguage: true

languages:
  ja:
    languageName: 日本語
    title: かずさプログラマーの雑記帳
    weight: 1
    params:
      sidebar:
        subtitle: 業務で作業自動化を行ってます。Golang/Python/VBAを使用してます

services:
  googleAnalytics:
    id: G-XXXXXXXXXX  # Google AnalyticsのトラッキングID

pagination:
  pagerSize: 5

permalinks:
  posts: /posts/:slug/
  page: /:slug/

params:
  mainSections:
    - posts
  featuredImageField: image
  rssFullContent: true
  favicon: /favicon.ico

  footer:
    since: 2018
    customText:

  dateFormat:
    published: '2006年1月2日'
    lastUpdated: '2006年1月2日 15:04'

  sidebar:
    emoji:
    subtitle: プログラミングとテクノロジーのブログ
    avatar:
      enabled: true
      local: true
      src: img/profile-picture.png

  article:
    math: true
    toc: true
    readingTime: true
    license:
      enabled: true
      default: Licensed under CC BY-NC-SA 4.0

  comments:
    enabled: true
    provider: giscus

    giscus: # giscus設定ページで取得した内容を設定
      repo: your-username/your-repo-name
      repoID: YOUR_REPO_ID
      category: General
      categoryID: YOUR_CATEGORY_ID
      mapping: pathname
      lightTheme: light
      darkTheme: dark
      reactionsEnabled: 1
      emitMetadata: 0

  widgets:
    homepage:
      - type: search
      - type: archives
        params:
          limit: 5
      - type: categories
        params:
          limit: 10
      - type: tag-cloud
        params:
          limit: 10
    page:
      - type: toc

menu:
  main:
    - identifier: home
      name: Home
      url: /
      weight: -100
      params:
        icon: home
        newTab: false

  social:
    - identifier: github
      name: GitHub
      url: https://github.com/kazusapg
      params:
        icon: brand-github

ショートコードの書き換え

Blowfishテーマ固有のショートコードはStackテーマでは動作しないため書き換える必要があります。手動で書き換えると時間がかかるため、GitHub Copilotを使用してすべて書き換えてもらいました。

主な変更内容

articleショートコード → 内部リンク

ブログ内の他の記事へのリンクに使用していたarticleショートコードを、通常のMarkdownリンクに変更しました。

変更後:

[VBAで参照設定を行う](/vba-references/)

alertショートコード → 引用記法

注意書きや補足情報を表示していたalertショートコードを、Markdownの引用記法に変更しました。

変更後:

> 注意事項や補足情報をここに記載

githubショートコード → 通常のリンク

GitHubリポジトリへのリンクに使用していたgithubショートコードを、通常のMarkdownリンクに変更しました。

変更後:

[https://github.com/user/repo](https://github.com/user/repo)

参考URL

Licensed under CC BY-NC-SA 4.0
Hugo で構築されています。
テーマ StackJimmy によって設計されています。