LoginSignup
2
2

More than 5 years have passed since last update.

静的サイトジェネレーターHugoのQuickstart Guideをやってみた

Last updated at Posted at 2016-05-07

hugoのインストール

以下の説明に沿って、hugoをインストールします。

https://gohugo.io/overview/installing/
On OS X, if you have Homebrew, installation is even easier: just run brew update && brew install hugo.

brew update && brew install hugo

bookshelfのひな形を作る

hugo new site bookshelf

下のような感じになります。

ディレクトリ.png

  • archetypes: You can create new content files in Hugo using the hugo newコマンドで生成されたコンテンツと設定ファイルが追加されます。

  • config.toml: デフォルトはTOMLですが、JSON, YAMLも利用できます。

  • content: ウェブサイトのコンテンツを管理する場所です。content内ではサブディレクトリを作成することができます。

  • data: Hugoで使用する設定ファイルを管理しておく場所です。config.tomlと同様にYAML, JSONが利用可能です。

  • layouts: レイアウト関連のファイルを置きます。

  • static: imagesやCSS, Jsなどの静的なファイルをすべて管理します。

記事をつくる

bookshelfディレクトリで以下のコマンドを実行します。

hugo new post/good-to-great.md

上記のコマンドでcontent内にgood-to-great.mdファイルができました。

good-to-great.png

テーマを追加する

テーマを管理するディレクトリを作成します。

mkdir themes && cd themes
git clone https://github.com/dim0627/hugo_theme_robust.git

hugo serverを起動する

bookshelfディレクトリに戻って以下のコマンドを実行します。

hugo server --theme=hugo_theme_robust --buildDrasts

hugo server時にどのテーマで起動するかを指定する必要があるようです。

hugo-site.png

できた。

上記の他にQuickstart Guideで説明されていることは以下の通りです。

  • 複数のテーマを使用する
  • config.tomlを更新して、ライブリロードでserverを起動する
    • hugo server --theme=hugo_theme_robust --buildDrafts robustをつければ良い
  • テーマをカスタマイズする
  • 記事を公開する(今までdraft=trueにしていたので)
    • hugo undraft content/post/good-to-great.mdした後にserver起動
  • 記事にコメント機能をつける
  • Github pagesにデプロイする

上記の説明とQuickstart Guideで異なる点

  • 説明の順序を変えています

上記の説明では、テーマ追加後にサーバーを起動していますが、
Quickstart Guideは逆になっています。
これは、テーマを追加しないとサーバーを起動しても意味がない(何も表示されない)

  • テーマをcloneするコマンド

Quickstart Guideの通りコマンドを実行すると、
以下のエラーになったため、コマンドを変えています。

git clone git@github.com:dim0627/hugo_theme_robust.git

Cloning into 'hugo_theme_robust'...
The authenticity of host 'github.com (192.30.252.128)' can't be established.

上記以外はすべてQuickstart Guide通りです。

感想

かんたん。

個人ブログでwordpressを使ってるのですが、MardDownがとても使いづらく、
hugoを始めようかなと思いQuickstart Guideをやってみました。

移行しようかな...

追記

hugo x Github Pagesでブログを作成したい場合には、
以下の記事が分かりやすいです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2