您可以为组织或个人帐户创建默认议题模板和默认的议题模板配置文件。有关更多信息,请参阅 创建默认社区健康文件。
创建议题模板
-
在 GitHub 上,导航至仓库的主页面。
-
在仓库名称下方,点击 设置。如果您没有看到“设置”标签,请选择 下拉菜单,然后点击 设置。

-
在“功能”部分的 议题 下,点击 设置模板。您可能需要先启用 议题 功能并刷新页面,才能看到此按钮。

-
使用 添加模板 下拉菜单,点击您想要创建的模板类型。

-
若要在提交到仓库之前预览或编辑模板,请在模板旁边点击 预览并编辑。
-
要编辑模板,请点击,并在字段中输入内容以编辑其内容。

-
要自动设置默认议题标题、将议题分配给具备仓库读取权限的人员,或为通过模板创建的议题添加标签,请在“可选的附加信息”下填写相应字段。您也可以在议题模板的 YAML 前置块中使用
title、labels、type或assignees来添加这些信息。 -
编辑并预览完模板后,点击页面右上角的 提出更改。
-
在 “提交信息” 字段中,输入描述您更改的提交信息。
-
在提交信息字段下方,选择是直接将模板提交到默认分支,还是创建新分支并打开拉取请求。有关拉取请求的更多信息,请参阅 关于拉取请求。
-
点击 提交更改。这些更改合并到默认分支后,模板即可供贡献者在仓库中打开新议题时使用。
创建议题表单
注意
问题表单目前处于公开预览阶段,可能会有更改。
使用议题表单,您可以创建带有可自定义网页表单字段的议题模板。通过在仓库中使用议题表单,您可以鼓励贡献者提供特定的结构化信息。
议题表单支持多种字段类型,包括文本输入、下拉列表、复选框和文件上传。议题表单采用 YAML 编写,遵循 GitHub 表单模式。更多信息请参阅 GitHub 表单模式的语法。如果您对 YAML 不熟悉并想进一步了解,请参阅 YAML 速学。
要在仓库中使用议题表单,必须新建一个文件并将其添加到仓库的 .github/ISSUE_TEMPLATE 目录下。
以下是议题表单配置文件的示例。
name: Bug Report
description: File a bug report.
title: "[Bug]: "
labels: ["bug", "triage"]
projects: ["octo-org/1", "octo-org/44"]
assignees:
- octocat
type: bug
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: contact
attributes:
label: Contact Details
description: How can we get in touch with you if we need more info?
placeholder: ex. email@example.com
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: What version of our software are you running?
options:
- 1.0.2 (Default)
- 1.0.3 (Edge)
default: 0
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: What browsers are you seeing the problem on?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com).
options:
- label: I agree to follow this project's Code of Conduct
required: true
- type: upload
id: screenshots
attributes:
label: Upload screenshots
description: If applicable, add screenshots to help explain your problem.
validations:
required: false
name: Bug Report
description: File a bug report.
title: "[Bug]: "
labels: ["bug", "triage"]
projects: ["octo-org/1", "octo-org/44"]
assignees:
- octocat
type: bug
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: contact
attributes:
label: Contact Details
description: How can we get in touch with you if we need more info?
placeholder: ex. email@example.com
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: What version of our software are you running?
options:
- 1.0.2 (Default)
- 1.0.3 (Edge)
default: 0
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: What browsers are you seeing the problem on?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com).
options:
- label: I agree to follow this project's Code of Conduct
required: true
- type: upload
id: screenshots
attributes:
label: Upload screenshots
description: If applicable, add screenshots to help explain your problem.
validations:
required: false
以下是议题表单的渲染效果。

- 选择您想要创建议题表单的仓库。您可以使用已有的、拥有写入权限的仓库,或创建一个新仓库。有关创建仓库的更多信息,请参阅 创建新仓库。
- 在您的仓库中,新建一个文件,命名为
.github/ISSUE_TEMPLATE/FORM-NAME.yml,将FORM-NAME替换为您议题表单的名称。有关在 GitHub 上新建文件的更多信息,请参阅 新建文件。 - 在新文件的正文中,输入议题表单的内容。更多信息请参阅 议题表单的语法。
- 将文件提交到仓库的默认分支。更多信息请参阅 新建文件。
配置模板选择器
通过在 .github/ISSUE_TEMPLATE 文件夹中添加 config.yml 文件,您可以自定义用户在仓库中创建新议题时看到的议题模板选择器。
您可以通过将 blank_issues_enabled 设置为 false 来鼓励贡献者使用议题模板。如果将 blank_issues_enabled 设置为 true,拥有仓库访问权限的所有人都会在模板选择器中看到 空白议题 选项。当 blank_issues_enabled 为 false 时,拥有写入或更高权限(写入、维护或管理员角色)的用户仍会在模板选择器中看到标记为 仅限维护者 的 空白议题 选项。具备只读或 triage 角色的贡献者只能看到已配置的模板。
注意
如果您使用旧版工作流手动在 .github 文件夹中创建了 issue_template.md 并在 config.yml 中启用了空白议题,则在用户选择打开空白议题时会使用 issue_template.md 中的模板。若禁用空白议题,则永不使用该模板。
如果您希望将某些报告引导至 GitHub 之外的外部站点,可使用 contact_links 进行链接。
以下是一个 config.yml 示例文件。
blank_issues_enabled: false
contact_links:
- name: GitHub Community Support
url: https://github.com/orgs/community/discussions
about: Please ask and answer questions here.
- name: GitHub Security Bug Bounty
url: https://bounty.github.com/
about: Please report security vulnerabilities here.
blank_issues_enabled: false
contact_links:
- name: GitHub Community Support
url: https://github.com/orgs/community/discussions
about: Please ask and answer questions here.
- name: GitHub Security Bug Bounty
url: https://bounty.github.com/
about: Please report security vulnerabilities here.
当该文件合并到仓库的默认分支后,您的配置文件将自定义模板选择器的显示。
-
在 GitHub 上,导航至仓库的主页面。
-
在文件列表上方,选择 添加文件下拉菜单,然后点击 创建新文件。
或者,您可以点击在左侧的文件树视图中。

-
在文件名字段中,输入
.github/ISSUE_TEMPLATE/config.yml。 -
在新文件的正文中,输入您的配置文件内容。
-
点击 提交更改...
-
在“Commit message”字段中,键入简短且有意义的提交信息,描述您对文件所做的更改。您可以在提交信息中将该提交归因于多个作者。欲了解更多信息,请参阅 创建拥有多位作者的提交。
-
在提交信息字段下方,决定是将提交添加到当前分支还是新分支。如果您当前的分支是默认分支,建议为提交创建一个新分支,然后发起拉取请求。欲了解更多信息,请参阅 创建拉取请求。

-
点击 提交更改 或 提议更改。
更改模板顺序
您可以通过修改模板文件名的方式设定模板在选择器中的显示顺序。.github/ISSUE_TEMPLATE 中的模板会按字母数字顺序列出,并按文件类型分组,YAML 文件会在 Markdown 文件之前。
要控制模板的显示顺序,请在文件名前加数字前缀。例如:1-bug.yml、2-feature-request.yml、3-epic.yml。
如果您拥有 10 个或以上的模板,字母数字排序会导致 11-bug.yml 位于 1-feature.yml 与 2-support.yml 之间。您可以在数字前再加一个前导 0 来保持预期顺序。例如:01-feature.yml、02-support.yml、11-bug.yml。