[hugo new post.md`创建新帖子时如何添加“标签”和“类别”

问题描述 投票:0回答:1

要创建新帖子,我会像这样运行:

hugo new posts/post.md

然后按如下所示生成文件:

---
title: "Post"
date: 2019-10-27T15:57:27+09:00
draft: true
---

通常我使用tagscategories,所以如果我可以默认添加它会更好。

---
title: "Post"
date: 2019-10-27T15:57:27+09:00
draft: true
categories:
tags:
---

我在哪里以及如何配置hugo new命令来完成此行为?

hugo
1个回答
1
投票

您要编辑posts/*.md文件的原型文件。有关此信息,请访问:

  1. https://gohugo.io/content-management/archetypes/

  2. https://www.ii.com/themeless-gitless-intro-hugo/#_edit_the_archetype_for_new_md_content_files

在#2 [*]中,它说:使用文本编辑器打开archetypes/default.md,如下所示:

---
## Important: If this is a draft, next line should NOT begin with #
# draft: true
title: {{ replace .Name "-" " " | title }}
date: {{ now.Format "2006-01-02" }}
## below are user-defined parameters (lower case keys recommended)
subtitle:
tags:
  - tag1
  - tag2
---

您可以将各种事物放入原型,包括身体内容。

我希望这会有所帮助,N(stackoverflow发布新手)

[*]我写了#2。我希望可以在此处自行链接。

© www.soinside.com 2019 - 2024. All rights reserved.