Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Go言語製のWebサイトエンジンHugoの機能整理 - Section

f:id:tbpg:20150811225844p:plain

Go言語製のWebサイトエンジンHugoの機能整理をします。
今回はSectionです。

Hugoとは?

Go言語製のWebサイトエンジンHugoの疎通確認

Sectionとは?

HugoのトップレベルのContent OrganizationをSectionとして扱う。
HugoはSectionに属する全てのページのリストを持つSectionルートを自動的に生成します。

Section と Type

デフォルトでは、Section名と同じtypeでContentを生成します。
異なるtypeを割り当てたい場合は、Front Matterに任意のtypeを設定します。

サンプル

設定

2つのSection (post, member)を作成します。

baseurl = "http://replace-this-with-your-hugo-site.com/"
languageCode = "ja"
title = "My New Hugo Site"
theme = "hugo_theme_beg"

[Params]
Author = "tbpgr"
DateForm = "Wen, Aug 8, 2015"
GoogleAnalyticsUserID = ""
Facebook = ""
Twitter = "tbpgr"
Github = "tbpgr"
ShowRelatedPost = true
Disqus = "unresolved"
SyntaxHighlightTheme = "github.min.css"

[Indexes]
tag = "tags"

[permalinks]
post = "/blog/:year/:month/:day/:slug/"

テーマのカスタマイズ

hugo_theme_begにmember Sectionを追加するために各種テンプレートをカスタマイズしました。
編集内容は省略。

content/post/esa.md

+++
title = "Esa"
date = "2014-09-17"
comments =true
tags = ["esa"]
+++

## esa
トリ

~~~ruby
class Esa
  def piyo
    puts "piyo"
  end
end
~~~

content/post/docbase.md

+++
title = "DocBase"
date = "2014-09-17"
comments =true
tags = ["DocBase"]
+++

## DocBase
■

content/member/tanaka.md

+++
title = "tanaka"
date = "2014-09-17"
name ="tanaka"
age =23
type ="member"
comments =true
+++

## 趣味
田中の会

content/member/suzuki.md

+++
title = "suzuki"
date = "2014-09-17"
name ="suzuki"
age =23
type ="member"
comments =true
+++

## 趣味
鈴木の会

動作確認

hugo server -wでサーバーを起動し、SectionごとにListのURLが出力されることを確認します。

Top Page

f:id:tbpg:20150812225900p:plain

post/esa

f:id:tbpg:20150812225725j:plain

post/docbase

f:id:tbpg:20150812225420j:plain

post

f:id:tbpg:20150812225949p:plain

member/tanaka

f:id:tbpg:20150812225959p:plain

member/suzuki

f:id:tbpg:20150812230008p:plain

member

f:id:tbpg:20150812230016p:plain

外部資料

Section - Content - Hugo