Hugoの設定(備忘録)
目次
いずれ自分の役に立つかも…?
とりあえず試してみた Hugo の設定やらなんやらをメモ. 基本的に自分用.
Hugoのインストール
WSL Ubuntu なら apt install で一発
sudo apt install hugo
GitHubのレポジトリ作成
- 公開用(
xxx.github.io) - 非公開作業用(
yyy)
yyyをcloneしておく
yyy直下でひな形作成
cd yyy
hugo new site sample
mv sample/* .
テーマの選定
Hugoは色んな人がテーマを提供しているが,その中で良さげなものを選択.
今回は
MainRoad
にしてみる.
MainRoad のdocumentation
を参考に,
themes/mainroadにサブディレクトリとしてインストール
cd /path/to/yyy
git submodule add https://github.com/vimux/mainroad.git themes/mainroad
config.tomlの編集
これもdocumentationを参考に作成
[Params]のauthorboxは不要- メニューは
[[Menus.main]]に指定 [[Params.widgets.social.custom]]を用いてORCiDなどを追加-
英語版ページ
も作成.
000x/index.en.mdとする.[languages.en]内に指定
layoutsの活用
shortcodes/r.html: markdown中に生htmlを書ける: {{< r >}}…{{< /r >}}_default/_markup/render-link.html: 新しいタブで開く(rel="noopener noreferrer"設定済)partialswidgets/twitter.html: Twitterタイムラインの埋め込みsvg: アイコンなど
その他
archetypes/default.md: 記事のデフォルト.mdファイルstatic/img: ホームのアイコンなど
Hugoをローカルでテストする場合
cd yyy
hugo -t mainroad
hugo server -D
localhost:1313にアクセス
公開の流れ
xxx.github.ioのpublicレポジトリ作成publicを作業用レポジトリyyyの管理下から外すgit rm -r public/xxx.github.ioを作業用レポジトリyyyのsubmoduleとして,publicに指定するgit submodule add https://github.com/xxx/xxx.github.io.git public