单页面模板
下面的单页面模板从 基础模板 继承了站点的外壳。
layouts/_default/single.html
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ end }}
查看模板查找顺序,以选择提供所需特定级别的模板路径。
下面的单页面模板从基础模板继承了站点的外壳,并渲染了页面标题、创建日期、内容以及“标签”分类法中关联的术语列表。
layouts/_default/single.html
{{ define "main" }}
<section>
<h1>{{ .Title }}</h1>
{{ with .Date }}
{{ $dateMachine := . | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := . | time.Format ":date_long" }}
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
{{ end }}
<article>
{{ .Content }}
</article>
<aside>
{{ with .GetTerms "tags" }}
<div>{{ (index . 0).Parent.LinkTitle }}</div>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
</aside>
</section>
{{ end }}