HUGO 靜態網站⽣生成器
2 分鐘上⼿手
Create Static Website with Hugo in 2 minutes
Fukuball Lin @ Go Taiwan
Slide 2
Slide 2 text
關於我
Fukuball / 林林志傑
Fukuball Lin @ Go Taiwan
簡介
幕僚僚⼯工程師
Slide 3
Slide 3 text
Hugo 是什什麼?
• 靜態網站⽣生成器,ex. Jekyll, Middleman, Roots
• 作者的抱怨:All had complicated installation dependencies and
took far longer to render my blog with its hundreds of posts than I
felt was acceptable.
• ⽤用 Go 寫的!
• I wanted to develop a fast and full-featured website framework
without any dependencies. The Go language seemed to have all
the features I needed in a language.
• 快!
• 實測 5000 篇⽂文章,⽣生成整個網站只需要 6 秒,其他⽣生成器則要數分
鐘
簡介
Fukuball Lin @ Go Taiwan
Slide 4
Slide 4 text
靜態網站好處
• 不⽤用⾃自⼰己 Host 資料庫
• 部署容易易,GitHub Page 就可以
Host
• ⽂文章修改在版控之中
簡介
Fukuball Lin @ Go Taiwan
專注於寫⽂文章!
Slide 5
Slide 5 text
安裝
• Mac:
• 其他平台:參參閱 https://gohugo.io/
overview/installing/
• 或者下載 Binary 執⾏行行檔
安裝
Fukuball Lin @ Go Taiwan
$ brew install hugo
Slide 6
Slide 6 text
兩兩分鐘上⼿手(1)
上⼿手
Fukuball Lin @ Go Taiwan
// 新建⼀一個靜態網站
$ hugo new site mysite
// 進入 theme ⽬目錄
$ cd mysite/themes
// 安裝 theme
$ git clone https://github.com/halogenica/beautifulhugo.git
// 回到根⽬目錄
$ cd ..
Slide 7
Slide 7 text
兩兩分鐘上⼿手(2)
上⼿手
Fukuball Lin @ Go Taiwan
// 打開編輯器
// 創建 archetypes/default.md,貼上:
+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = true
subtitle = ""
tags = []
+++
// 修改 config.toml 內容
Slide 8
Slide 8 text
兩兩分鐘上⼿手(3)
上⼿手
Fukuball Lin @ Go Taiwan
$ hugo new about.md
$ hugo new post/go.md
$ hugo new post/php.md
$ hogo new post/python.md
$ hugo server -t beautifulhugo --buildDrafts
// 完成!!!!
$ hugo -t beautifulhugo
// Build static pages