【Hugo】チートシート
フロントマターでNoIndexを設定する
robotsNoIndex: trueを追加すればOK.
Papermodではhead.htmlで定義されている。
{{- if hugo.IsProduction | or (eq site.Params.env "production") | and (ne .Params.robotsNoIndex true) }}
<meta name="robots" content="index, follow">
{{- else }}
<meta name="robots" content="noindex, nofollow">
{{- end }}
csvファイルをレンダリングする
- layouts_shortcodes\csv-table.html を作成
{{< csv-table "csvファイル名" >}}でテーブルにレンダリングされる。
{{ $fileName := .Get 0 }}
{{ $csvFile := .Page.Resources.GetMatch $fileName }}
{{ if $csvFile }}
{{ $csv := $csvFile | transform.Unmarshal (dict "delimiter" ",") }}
<div class="table-responsive">
<table class="styled-csv-table">
<thead>
<tr>
{{ range index $csv 0 }}
<th>{{ . }}</th>
{{ end }}
</tr>
</thead>
<tbody>
{{ range after 1 $csv }}
<tr>
{{ range . }}
<td>{{ . }}</td>
{{ end }}
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<p class="error">リーフバンドル内にCSVファイル "{{ $fileName }}" が見つかりませんでした。</p>
{{ end }}