Go言語製のWebサイトエンジンHugoの疎通確認までをまとめます
特徴
Go言語製ということで、Goのコマンドラインツールの利点が際立っています
- インストールが簡単
- バイナリが配布されている
- go環境があるなら
go get
でもよい
- マルチプラットフォーム
- 早い
- ミリ秒単位でビルドを完了
- 何処へでもホストできる
- 設定ファイルフォーマット
- YAML
- TOML
- TOMLについては => トムさんが作った設定ファイル用ミニ言語TOMLって? #toml
- JSON
- その他の特徴
特に、MiddlemanをWindows環境で利用する場合は、ハマりどころがあるため
そういった面で浪費しないで済むありがたさがある。
参考までにMiddlemanをWindows環境に入れる場合の問題が書かれた記事が下記。
dev.classmethod.jp dev.classmethod.jp
インストール
自分の環境にあったバイナリを取得します。
(私は、Windows7環境で試しました。)
2015/08/11時点の最新版であるv0.14をインストールします。
- バイナリをダウンロードします
- 解凍します
- パスが通った場所にexeを移動します
- 移動時にファイル名を
hugo_0.14_windows_amd64.exe
からhugo.exe
に変更しました。
- 移動時にファイル名を
- 疎通確認
$ hugo version Hugo Static Site Generator v0.14 BuildDate: 2015-05-26T10:29:16+09:00
Help
Helpをながめてみる
$ hugo --help hugo is the main command, used to build your Hugo site. Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io Usage: hugo [flags] hugo [command] Available Commands: server Hugo runs its own webserver to render the files version Print the version number of Hugo config Print the site configuration check Check content in the source directory benchmark Benchmark hugo by building a site a number of times new Create new content for your site undraft Undraft changes the content's draft status from 'True' to 'False' genautocomplete Generate shell autocompletion script for Hugo gendoc Generate Markdown documentation for the Hugo CLI. help Help about any command Flags: -b, --baseUrl="": hostname (and path) to the root eg. http://spf13.com/ -D, --buildDrafts=false: include content marked as draft -F, --buildFuture=false: include content with publishdate in the future --cacheDir="": filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/ --config="": config file (default is path/config.yaml|json|toml) -d, --destination="": filesystem path to write files to --disableRSS=false: Do not build RSS files --disableSitemap=false: Do not build Sitemap file --editor="": edit new content with this editor, if provided -h, --help=false: help for hugo --ignoreCache=false: Ignores the cache directory for reading but still writes to it --log=false: Enable Logging --logFile="": Log File path (if set, logging enabled automatically) --noTimes=false: Don't sync modification time of files --pluralizeListTitles=true: Pluralize titles in lists using inflect -s, --source="": filesystem path to read files relative from --stepAnalysis=false: display memory and timing of different steps of the program -t, --theme="": theme to use (located in /themes/THEMENAME/) --uglyUrls=false: if true, use /filename.html instead of /filename/ -v, --verbose=false: verbose output --verboseLog=false: verbose logging -w, --watch=false: watch filesystem for changes and recreate as needed Additional help topics: hugo convert Convert will modify your content to different formats hugo list Listing out various types of content Use "hugo help [command]" for more information about a command.
疎通確認
テンプレートを生成する
$ hugo new site hugo_and_ryu $ tree . ├── content │ └── hugo_and_ryu ├── hugo_and_ryu │ ├── archetypes │ ├── config.toml │ ├── content │ ├── data │ ├── layouts │ └── static └── public ├── 404.html ├── index.html ├── index.xml └── sitemap.xml
テーマを変えてみる
以下のテーマを使ってみます。
hugoscroll - GitHub
テーマのダウンロード
$ git clone https://github.com/SenjinDarashiva/hugoscroll themes/hugoscroll
TOMLの設定
baseurl = "http://replace-this-with-your-hugo-site.com/" languageCode = "ja" title = "My New Hugo Site" theme = "hugoscroll"
ページの追加
content/first.md
+++ title = "What is this" description = "First post" weight = 1 type = "post" class="post first" +++ ## Hoge Test ## Hige Test ## Hage Test
content/last.md
+++ title = "Finaly!" description = "Last Post" weight = 100 type = "post" class="post last" +++ ## Hoge Test ## Hige Test ## Hage Test
デモ
http://127.0.0.1:1313/ にアクセスして動作確認をします