windows10 cmd(mingw)
で行った時のメモ
hugo new site siteName
.
┣━━archetypes/
┃ 'hugo new' コマンドで生成するコンテンツのひな型格納場所
┣━━content/
┃ コンテンツ格納場所
┣━━data/
┃ JSONやYAML、TOML形式のデータ格納場所
┣━━layouts/
┃ themesのテーマを上書きするレイアウト格納場所
┣━━static/
┃ 静的ファイル格納場所(メディアファイルなど)
┣━━themes/
┃ テーマ格納場所
┗━━hugo.toml(config.toml)
サイトの構成ファイル
hugoの PaperMod テーマを 'theme/PaperMod' フォルダに追加する。
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
※v0.109.0
から設定ファイルはhugo.toml
設定ファイルを編集したい場合は、hugo.toml
を編集
例えば、コードブロックにコピーボタンを追加したい場合は
hugo.toml
に以下を追加する。
[params]
ShowCodeCopyButtons = true
themes\PaperMod
にある README.md
とgit関連
のファイル以外をコピーする。
サイト直下にコピーしたものを全て上書きする。
以下のコマンドでローカルで起動する事が出来る。
hugo server -D
-Dオプション、下書き(Draft)として定義したコンテンツもプレビュー結果に表示する。
netlify.toml
を新規作成して
Host on Netlifyを参考に
[build]
publish = "public"
command = "hugo --gc --minify"
[build.environment]
HUGO_VERSION = "0.121.2"
[context.production.environment]
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.split1]
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"
[[redirects]]
from = "/npmjs/*"
to = "/npmjs/"
status = 200
のような内容をコピーして、version
情報を自身のhugoに合わせて変更して保存
その後、Netlifyでアカウントを作成し、道なりに設定。
hugoサイト直下で、以下のコマンドを実行することで
フォルダcontent/post
とファイルcontent/post/my-first-post.md
を生成し、コンテンツを作成する。
hugo new posts/my-first-post.md
また、archettypes/default.md
を編集する事で、投稿する記事のデフォルトの設定を変更できる。