0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Hugoで`new content`した時に挿入されるフロントマターを編集したい

Posted at

はじめに

Hugoでブログを書き始めたのですが、

hugo new content hogehoge

した際に作成されるファイルへ自動的に挿入されるフロントマターを編集したい…となったのでそのメモです。

default.mdを編集

hugo new site hogehogeで作成されるディレクトリの配下に存在する/archetypes/default.mdを編集します。

hugo v0.143.1で作成されるdefault.mdの初期値は以下でした。

  +++
  date = '{{ .Date }}'
  draft = true
  title = '{{ replace .File.ContentBaseName "-" " " | title }}'
  +++

ここに、毎回追記していた設定を追記します。

  +++
  date = '{{ .Date }}'
  draft = true
  title = '{{ replace .File.ContentBaseName "-" " " | title }}'
+ description = ''
+ categories = ['']
+ tags = ['']
+ image = ''
  +++

hugo new content hogehogeしてみて、挿入されるフロントマターが変わっていればOKです。

その他

/archetypes/default.mdと同じ場所に別のテンプレートファイルを配置する事もできるみたいです。 1

参考

  1. https://gohugo.io/content-management/archetypes/#specify-archetype

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?