Skip to content

Instantly share code, notes, and snippets.

@neon-izm
Created November 3, 2017 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neon-izm/d85a29c7b6f7bd27ebc55e88ff5af980 to your computer and use it in GitHub Desktop.
Save neon-izm/d85a29c7b6f7bd27ebc55e88ff5af980 to your computer and use it in GitHub Desktop.
現実逃避にHugoでサイトを置き換える

手元にWindowsしかなかったので…たぶん2017年現在に、ブログっぽいのをmarkdownで書いて静的サイトでホスティングするなら一番お手軽な気がします。

1. chocolateyをインストール

https://chocolatey.org/install を参考に

2. chocolatey でHugoをインストール

Jekyll(Ruby)よりHugo(Go)の方がWindowsだと楽なはず…

コマンドプロンプトを管理者で実行して

C:\WINDOWS\system32>choco install hugo

をやってYキーでインストール。

無事インストール出来たかは同じくコマンドプロンプト上で

hugo version

をタイプして

Hugo Static Site Generator v0.30.2 windows/amd64 BuildDate: 2017-11-04T01:21:00+09:00

みたいな文字列が返って来てればOK

この手軽さはすごいですね…

3. Hugoのquick startに沿ってサイトを作成する

https://gohugo.io/getting-started/quick-start/

を見たまま進めれば大丈夫ですね。 ローカルのPC上に新しいサイト用ディレクトリを作っておいて

そのディレクトリ上で

hugo newsite ○○

とやるとひな形が出来上がります。 achetypesとかcontentとかいろんなフォルダが中に出来ていればOKぽいです。

4. テンプレートをダウンロードする

たぶんさすがにgit無しでやるのはつらいので、 git init出来なかったら choco install git.install

とやってgitも入れておきましょう。(このPC入ってなかった…)

cd quickstart

してから

git init

して

git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke

とやる感じで(公式だと一発インストールになってたかも?)

hugo new posts/my-test-post.md して hugo server -D

やれば http://localhost:1313/

でサイトを見られます。 初期設定のままだと、中のファイルを書き換えるたびに自動で更新が走ってくれます。

5. htmlの静的サイトを書き出す

hugo とだけ打って実行すると publicフォルダが出来て、中身にhtmlがウワッと出てきます。 後はFTPでもSFTPでもまともなgit hookでもお好きにやれますね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment