8000 GitHub - ungeho/hugo-Myblog
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ungeho/hugo-Myblog

Repository files navigation

Hugoを試しに触ってみるメモ

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

hugo.toml(config.toml)(サイトの構成ファイル)の追加と編集

v0.109.0から設定ファイルはhugo.toml

設定ファイルを編集したい場合は、hugo.tomlを編集

PaperModの設定項目

Tomlの書式

例えば、コードブロックにコピーボタンを追加したい場合は

hugo.tomlに以下を追加する。

[params]
    ShowCodeCopyButtons = true

テーマの反映

themes\PaperMod にある README.mdgit関連のファイル以外をコピーする。

サイト直下にコピーしたものを全て上書きする。

以下のコマンドでローカルで起動する事が出来る。

hugo server -D

-Dオプション、下書き(Draft)として定義したコンテンツもプレビュー結果に表示する。

Netlifyでデプロイ(公開)する。

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を編集する事で、投稿する記事のデフォルトの設定を変更できる。

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0