Hugoでブログ構築&Mainroadテーマを適用

記事に広告リンクを含む場合があります。

Hugoでブログ構築&Mainroadテーマを適用

構築手順

詳細はZennに投稿しました。
Hugo + GitHub + Netlifyで静的ブログサイト構築(無料)

Google Analyticsの追加

  • 下記をconfig.tomlに追加
    googleAnalytics = "UA-XXX-XXX"

  • 下記をbaseof.htmlに追加
    {{ template "_internal/google_analytics.html" . }}

Mainroad設定(config.toml)

Mainroad関連の設定を含め、このブログの設定値の一部を記載します。

DefaultContentLanguage = "en"
languageCode = "ja"
title = "YSMLOG"
theme = "mainroad"
paginate = 5
googleAnalytics = "UA-XXX-XXX"
enableRobotsTXT = false
hasCJKLanguage = true
summaryLength = 100

[Params]
highlightColor = "#abcdef"
twitter_cards = true
readmore = true
pager = true
post_meta = ["date", "categories"]
opengraph = true
images = ["/img/default.webp"]
dateformat = "2006-01-02"
googleFontsLink = "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700&display=swap"
customCSS = ["css/custom.css"]

[Params.sidebar]
home = "right"
list = "right"
single = true
widgets = ["recent", "social", "categories"]

[Params.widgets]
recent_num = 5

[Params.widgets.social]
twitter = "ysmlife1"

[[Menus.main]]
Name = "Top"
URL = "/"
weight = 1

[[Menus.main]]
Name = "Blog"
URL = "/categories/blog/"
weight = 2

[[Menus.main]]
Name = "Programming"
URL = "/categories/programming/"
weight = 3

[[Menus.main]]
Name = "PC"
URL = "/categories/pc/"
weight = 4

[[Menus.main]]
Name = "Procedure"
URL = "/categories/procedure/"
weight = 5

[[Menus.footer]]
Name = "Privacy"
URL = "/privacy/"

Hugoコマンドメモ

  • 動作確認
    hugo server -D
    http://localhost:1313/ でローカルサーバー上で確認できます。

  • 静的ページ作成
    hugo -D